docs/developer/multi-store/quickstart.mdx
To enable multiple stores, you will need to add the spree_multi_store gem to your project via:
bundle add spree_multi_store
If you would like to use it in a commercial application, please contact us to obtain a commercial license. </Info>
<Frame type="glass" caption="Spree multi-store setup">  </Frame>Each Store can have its own resources. For example, a Store can have its own Products, Taxonomies, Promotions, etc.
| Resource | Relationship |
|---|---|
| Order | One Order belongs to one Store |
| Product | One Product can be associated with many Store(s), you can pick and choose in which Store(s) each Product will be available |
| Payment Method | One Payment Method can be associated with many Store(s), you can select in which Stores given Payment Method will be available on Checkout |
| Taxonomy | One Taxonomy belongs to one Store |
| Promotion | One Promotion can be associated with multiple Stores |
| Store Credit | One Store Credit belongs to and can be used in one Store |
Spree will try to determine the current store based on the current URL. If the URL does not match any of the stores in the database, Spree will fall back to the default store.
All Spree controllers or any other controllers that include Spree::Core::ControllerHelpers::Store have access to the current_store method which returns the Store matching the current URL.
All parts of Spree (API, Admin Panel) have this implemented.
<Info> Under the hood `current_store` calls [Spree::Stores::FindCurrent.new(url: url).execute](https://github.com/spree/spree/blob/main/core/app/finders/spree/stores/find_current.rb).This logic can be easily overwritten by setting
Spree::Dependencies.current_store_finder = 'MyStoreFinderClass'
in config/initializers/spree.rb file
</Info>
If the system cannot find any Store that matches the current URL it will fall back to the Default Store.
You can set the default Store via Rails console:
Spree::Store.find(2).update(default: true)
To get the default store in your code or rails console type:
Spree::Store.default
Spree supports managing custom domains for Stores. In the Admin Panel, you can manage custom domains for each Store in the Settings -> Domains page.
Follow the setup guide to get started.