> ## Documentation Index
> Fetch the complete documentation index at: https://spreecommerce.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Multi-Store Spree Commerce

To enable multiple stores, you will need to add the `spree_multi_store` gem to your project via:

```bash theme={"theme":"night-owl"}
bundle add spree_multi_store
```

<Info>
  Spree Multi-Store is licensed under the [AGPL v3 License](https://opensource.org/licenses/AGPL-3.0).

  If you would like to use it in a commercial application, please [contact us](https://spreecommerce.org/get-started/) to obtain a commercial license.
</Info>

<Frame type="glass" caption="Spree multi-store setup">
  <img src="https://mintcdn.com/spreecommerce/cQFxCIv2IPZLev6h/images/mulit_store_978x2.png?fit=max&auto=format&n=cQFxCIv2IPZLev6h&q=85&s=d04d76064ebf23b67b2796ddb4418004" alt="" width="1956" height="1022" data-path="images/mulit_store_978x2.png" />
</Frame>

## Store resources

Each Store can have its own resources. For example, a Store can have its own Products, Taxonomies, Promotions, etc.

| Resource                                                      | Relationship                                                                                                                               |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| [**Order**](/core-concepts/orders)                            | One Order belongs to one Store                                                                                                             |
| [**Product**](/core-concepts/products)                        | 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**](/core-concepts/payments)                 | 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**](/core-concepts/products#taxons-and-taxonomies) | One Taxonomy belongs to one Store                                                                                                          |
| [**Promotion**](/core-concepts/promotions)                    | One Promotion can be associated with multiple Stores                                                                                       |
| **Store Credit**                                              | One Store Credit belongs to and can be used in one Store                                                                                   |

## Current 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](https://github.com/spree/spree/blob/main/core/lib/spree/core/controller_helpers/store.rb) 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

  ```ruby theme={"theme":"night-owl"}
  Spree::Dependencies.current_store_finder = 'MyStoreFinderClass'
  ```

  in `config/initializers/spree.rb` file
</Info>

## Default Store

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:

```ruby theme={"theme":"night-owl"}
Spree::Store.find(2).update(default: true)
```

To get the default store in your code or rails console type:

```ruby theme={"theme":"night-owl"}
Spree::Store.default
```

## Custom Domains

Spree supports managing custom domains for Stores. In the Admin Panel, you can manage custom domains for each Store in the **Settings -> Domains** page.

## Setup multi-store application

[Follow the setup guide](/developer/multi-store/setup) to get started.
