Class: Spree::Stores::ProvisionDefaults
- Inherits:
-
Object
- Object
- Spree::Stores::ProvisionDefaults
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree/stores/provision_defaults.rb
Overview
Creates the per-store defaults whose shape depends on where the shop is: the default market, the warehouse, the delivery zones and their methods, and pickup. The seeds cannot build these, because when they run nobody has said which country the shop sells from yet — so they are built here, from the merchant's answer, rather than seeded as US and rewritten later.
Two callers only (docs/plans/6.0-store-context-and-first-run-setup.md): the first-run setup endpoint, and the env-credential branch of Spree::Seeds::AdminUser. Never wire this to a settings screen — run against a configured store it reads as a data reset.
Constant Summary collapse
- DOMESTIC_AMOUNT =
5- INTERNATIONAL_AMOUNT =
20
Instance Method Summary collapse
-
#call(store:, country:, locale: nil, currency: nil) ⇒ Spree::Store
The store, reloaded.
Methods included from Spree::ServiceModule::Base
Instance Method Details
#call(store:, country:, locale: nil, currency: nil) ⇒ Spree::Store
Returns the store, reloaded.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/services/spree/stores/provision_defaults.rb', line 28 def call(store:, country:, locale: nil, currency: nil) @store = store @country = country @currency = resolve_currency(currency, country) @locale = resolve_locale(locale, country) # Defaults are bookkeeping, not merchant actions — webhooks and # subscribers should not hear about each zone and method created here. Spree::Events.disable do ApplicationRecord.transaction do update_default_market provision_stock_location provision_delivery_zones provision_package_type provision_pickup restate_seeded_calculators end end store.reload end |