Class: Spree::Seeds::Channels

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree/seeds/channels.rb

Overview

Seeds the gated Wholesale channel every store ships with by default — the reference "blended DTC + B2B" setup: the default channel stays public while wholesale requires login and forbids guest checkout. See docs/plans/5.6-store-channel-context-and-key-binding.md.

Constant Summary collapse

WHOLESALE_CODE =
'wholesale'.freeze

Instance Method Summary collapse

Methods included from Spree::ServiceModule::Base

prepended

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/spree/seeds/channels.rb', line 12

def call
  Spree::Store.find_each do |store|
    store.ensure_default_channel

    store.channels.find_or_create_by!(code: WHOLESALE_CODE) do |channel|
      channel.name = 'Wholesale'
      channel.preferred_storefront_access = 'login_required'
      channel.preferred_guest_checkout = false
    end
  end
end