@spree/docs 0.1.108 → 0.1.109

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -579,38 +579,6 @@ Here's a list of all places you can inject your custom code:
579
579
  </details>
580
580
 
581
581
 
582
- ### Custom Domains
583
-
584
- <details>
585
- <summary>Custom Domains Actions</summary>
586
-
587
- `custom_domains_actions`
588
-
589
- Injects code into the page actions area for the custom domains list page.
590
-
591
- ```erb
592
- <%= link_to "Verify All Domains", verify_all_domains_path, class: "btn btn-secondary" %>
593
- ```
594
-
595
- </details>
596
-
597
-
598
- <details>
599
- <summary>Custom Domains Header</summary>
600
-
601
- `custom_domains_header`
602
-
603
- Injects code between the page header and the main content area for the custom domains list page.
604
-
605
- ```erb
606
- <div class="alert alert-info">
607
- <strong>SSL:</strong> SSL certificates are automatically managed.
608
- </div>
609
- ```
610
-
611
- </details>
612
-
613
-
614
582
  ### Customer Returns
615
583
 
616
584
  <details>
@@ -5,9 +5,7 @@ description: Understand Spree Stores — the top-level tenant boundary that scop
5
5
 
6
6
  ## Overview
7
7
 
8
- The Store is the top-level tenant in Spree. Every resource — products, orders, channels, markets, taxonomies — belongs to exactly one store. A store owns its branding (logo, custom domain, mail-from address), its [channels](channels.md) (online, POS, wholesale, …), its [markets](markets.md) (region/currency/locale), and its catalog.
9
-
10
- ## Store Attributes
8
+ The StThe Store is the top-level tenant in Spree. Every resource — products, orders, channels, markets, taxonomies — belongs to exactly one store. A store owns its [channels](channels.md) (online, POS, wholesale, …), its [markets](markets.md) (region/currency/locale), and its [product catalog](products.md).tore Attributes
11
9
 
12
10
  | Attribute | Description |
13
11
  |-----------|-------------|
@@ -5,16 +5,6 @@ sidebarTitle: Configuration
5
5
 
6
6
  Multi-tenant applications include additional configuration options. All configuration should be placed in `config/initializers/spree_multi_tenant.rb` file.
7
7
 
8
- ### Root domain
9
-
10
- To make multi-tenant, you need a root/wildcard domain, eg. `*.example.com`. Tenant stores are usually accessed via subdomains, eg. `store1.example.com`, `store2.example.com`, etc.
11
-
12
- ```bash
13
- Spree.root_domain = 'example.com'
14
- ```
15
-
16
- Still your tenants will be able to add custom domains, eg. `myflowerstore.com` via the Spree admin panel. Tenant subdomains are used only for admin panel access.
17
-
18
8
  ### App subdomain
19
9
 
20
10
  Application subdomains is used to access the application, eg. `app.example.com`. By default for existing tenants it will redirect them to their tenant subdomain, eg. `store1.example.com`. If you want, you can also use this as a tenant signup/store setup page, this is available under `app.example.com/tenants/new`.
@@ -1,80 +1,36 @@
1
1
  ---
2
- title: Spree Multi Tenant Installation
3
- sidebarTitle: Installation
4
- description: Install and configure Spree Multi-Tenant to run a SaaS ecommerce platform, including prerequisites, gem setup, license keys, and tenant provisioning.
2
+ title: Create a multi-tenant / SaaS platform on top of Spree
3
+ sidebarTitle: Quickstart
4
+ description: Configure Spree to run a SaaS ecommerce platform, including prerequisites, gem setup, license keys, and tenant provisioning.
5
5
  ---
6
6
 
7
- > **WARNING:** This installation instructions assume you have a clean Spree Starter installation and you've purchased the [Spree Enterprise Edition license](https://spreecommerce.org/pricing).
8
- >
9
- > For migrating existing application from single-tenant to multi-tenant, please contact us at [support@spreecommerce.org](mailto:support@spreecommerce.org).
7
+ > **INFO:** Multi-tenancy requires [Spree Enterprise Edition license](https://spreecommerce.org/pricing).
10
8
 
11
- ## Prerequisites
12
-
13
- * You need to be on Spree 5.1+, we recommend using [spree_starter](https://github.com/spree/spree_starter) as a base for your application
14
- * You need to have 2 environment variables set:
15
- * `KEYGEN_ACCOUNT_ID`
16
- * `KEYGEN_LICENSE_KEY`
17
- * We support both PostgreSQL and MySQL databases
18
-
19
- > **INFO:** Environment variables will be provided to you after purchasing the [Spree Enterprise Edition license](https://spreecommerce.org/pricing).
20
-
21
- > **WARNING:** You will need to add these environment variables to your CI/CD pipeline and production environments.
22
-
23
- ## Customer User Class
9
+ Spree can be configured to run a multi-tenant / SaaS platform. This guide will walk you through the steps to set up your Spree application to support multiple tenants (stores).
10
+ Each tenant (store) can have its own isolated data and configuration, including:
24
11
 
25
- Please follow [Authentication](../customization/authentication.md) documentation to create a new user class.
12
+ * customer accounts
13
+ * staff accounts (admin users), staff can manage multiple tenants (it's the standard invitation flow)
14
+ * products, categories, and other catalog data
15
+ * orders and order history
16
+ * shipping and payment methods
17
+ * tax rates and zones
18
+ * store settings (name, logo, etc.)
19
+ * etc.
26
20
 
27
- Now we will need to make slight adjustments to the generated user class so it can work in a multi-tenant environment.
21
+ All data is fully isolated besided the staff users, which can manage multiple tenants. This allows you to create a SaaS platform where each tenant can have its own store with its own branding and configuration. Isolation works across admin dashboard and API.
28
22
 
29
- If you're using Devise, you will need to remove `:validatable` module. This module is responsible for validating the user's email uniqueness. We need to change it to validate it in the scope of the tenant.
23
+ > **INFO:** If you need individual seller/supplier/vendor accounts but shared product listings under one site you should use [multi vendor recipe](../multi-vendor.md) instead.
30
24
 
31
- Spree Multi-Tenant gem injects `SpreeMultiTenant::CustomerUserConcern` that handles that instead.
32
-
33
- ## Admin User Class
34
-
35
- For our multi-tenant setup we will need a separate Admin user class. Our standard User class will be only used for customer accounts which will be isolated by tenant.
36
- Admin user classes will be shared across tenants allowing them to manage multiple tenants from a single admin panel.
37
-
38
- Let's create a new model with Devise (unless you already have one):
39
-
40
-
41
- ```bash Spree CLI (Docker)
42
- spree rails g devise Spree::AdminUser
43
- ```
44
-
45
- ```bash Without Spree CLI
46
- bin/rails g devise Spree::AdminUser
47
- ```
48
-
49
-
50
- Replace the generated Devise code with the following:
51
-
52
- ```ruby
53
- class Spree::AdminUser < Spree::Base
54
- # Include default devise modules. Others available are:
55
- # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
56
- devise :database_authenticatable, :registerable,
57
- :recoverable, :rememberable, :validatable
58
-
59
- # Spree modules
60
- include Spree::UserMethods
61
- end
62
- ```
63
-
64
- If you already have a custom Admin user class, you can add the following code to it:
65
-
66
- ```ruby
67
- # Spree modules
68
- include Spree::UserMethods
69
- ```
70
-
71
- This will make sure that the Admin user class works well with Spree ecosystem.
25
+ ## Prerequisites
72
26
 
73
- Register new model in `config/initializers/spree.rb`:
27
+ * You need to be on Spree 5.1+, we recommend using [CLI](../getting-started.md) to setup your Spree application.
28
+ * You need to set 2 environment variables in your `backend` directory:
29
+ * `KEYGEN_ACCOUNT_ID`
30
+ * `KEYGEN_LICENSE_KEY`
31
+ * Both PostgreSQL and MySQL are supported
74
32
 
75
- ```ruby
76
- Spree.admin_user_class = "Spree::AdminUser"
77
- ```
33
+ > **INFO:** You will need to add these environment variables to your CI/CD pipeline and staging/production environments.
78
34
 
79
35
  ## Installing gems
80
36
 
@@ -116,3 +72,37 @@ Spree.admin_user_class = "Spree::AdminUser"
116
72
 
117
73
 
118
74
  > **INFO:** This will copy and run migrations for `spree_enterprise` and `spree_multi_tenant` gems.
75
+
76
+
77
+ ## Setting root domain
78
+
79
+ Usually multi-tenant applications are configured to use subdomains for each tenant. For example, if your root domain is `example.com`, you can have tenants like `tenant1.example.com`, `tenant2.example.com`, etc.
80
+ To make it work you need to set the `Spree.root_domain` in your `config/initializers/spree.rb` file, eg.
81
+
82
+ ```ruby
83
+ Spree.root_domain = 'example.com'
84
+ ```
85
+
86
+ or use environment variable:
87
+
88
+ ```ruby
89
+ Spree.root_domain = ENV.fetch('SPREE_ROOT_DOMAIN', 'localhost')
90
+ ```
91
+
92
+ This way you can also test it locally using `localhost` as root domain, and use `tenant1.localhost`, `tenant2.localhost`, etc. for tenants.
93
+
94
+ ## Customer User Class adjustment
95
+
96
+ We need to make slight adjustments to the user class so it can work in a multi-tenant environment.
97
+
98
+ You need to remove `:validatable` module. This module is responsible for validating the user's email uniqueness. We need to change it to validate it in the scope of the tenant.
99
+
100
+ ```ruby backend/app/models/spree/user.rb
101
+ class User < ApplicationRecord
102
+ devise :database_authenticatable, :registerable, :validatable # [!code --]
103
+ devise :database_authenticatable, :registerable, # [!code ++]
104
+ :recoverable, :rememberable, :trackable, :confirmable
105
+
106
+ include SpreeMultiTenant::CustomerUserConcern # [!code ++]
107
+ end
108
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spree/docs",
3
- "version": "0.1.108",
3
+ "version": "0.1.109",
4
4
  "description": "Spree Commerce developer documentation for AI agents and local reference",
5
5
  "type": "module",
6
6
  "license": "CC-BY-4.0",