Module: Spree::Channel::Gating
- Extended by:
- ActiveSupport::Concern
- Included in:
- Spree::Channel
- Defined in:
- app/models/spree/channel/gating.rb
Overview
Storefront access gating for a channel. Decides what an anonymous
(not-logged-in) visitor may see and whether an order may be placed
without an account. Both controls fall back to the owning Store when the
channel preference is unset, mirroring OrderRouting::HasStrategyPreference.
Constant Summary collapse
- STOREFRONT_ACCESS =
Posture controlling catalog/price visibility for anonymous visitors:
publicproducts + prices visible to anyoneprices_hiddenproducts browsable, prices null for guestslogin_requiredcatalog reads rejected for guests
%w[public prices_hidden login_required].freeze
Instance Method Summary collapse
-
#resolved_guest_checkout ⇒ Boolean
Whether guest checkout is allowed: the channel preference, or the store fallback when the channel value is unset.
-
#resolved_storefront_access ⇒ String
The effective access posture: the channel preference, or the store fallback when unset, defaulting to
public. -
#storefront_login_required? ⇒ Boolean
True when guests must authenticate before browsing.
-
#storefront_prices_hidden? ⇒ Boolean
True when guests must not see prices on this channel.
Instance Method Details
#resolved_guest_checkout ⇒ Boolean
Returns whether guest checkout is allowed: the channel preference, or the store fallback when the channel value is unset.
36 37 38 39 40 41 |
# File 'app/models/spree/channel/gating.rb', line 36 def resolved_guest_checkout value = preferred_guest_checkout return value unless value.nil? store.nil? ? true : store.preferred_guest_checkout end |
#resolved_storefront_access ⇒ String
Returns the effective access posture: the channel preference,
or the store fallback when unset, defaulting to public.
28 29 30 31 32 |
# File 'app/models/spree/channel/gating.rb', line 28 def resolved_storefront_access preferred_storefront_access.presence || store&.preferred_storefront_access.presence || 'public' end |
#storefront_login_required? ⇒ Boolean
Returns true when guests must authenticate before browsing.
49 50 51 |
# File 'app/models/spree/channel/gating.rb', line 49 def storefront_login_required? resolved_storefront_access == 'login_required' end |
#storefront_prices_hidden? ⇒ Boolean
Returns true when guests must not see prices on this channel.
44 45 46 |
# File 'app/models/spree/channel/gating.rb', line 44 def storefront_prices_hidden? resolved_storefront_access == 'prices_hidden' end |