Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Updated Spree Core section and added Core Stores section

Damian Legawiecd3f3dd7f972c
diff --git a/guides/src/content/developer/core/addresses.md b/guides/src/content/developer/core/addresses.md
index e163a2ad3c..f232dc4f6e 100644
--- a/guides/src/content/developer/core/addresses.md
+++ b/guides/src/content/developer/core/addresses.md
@@ -26,7 +26,7 @@ Addresses can also link to countries and states. An address must always link to
As of Spree 4.0 `Spree::User` can have multiple addresses and can manage them on the Checkout and Account page. Previously this feature was part of the [Spree Address Book](https://github.com/spree-contrib/spree_address_book) extension. Each `Spree::Address` object has a `user_id` column which links to the User.
-Additionaly in the `Spree::User` model you have `ship_address_id` and `bill_address_id` columns which indicates default shipping and billing addresses.
+Additionaly in the `Spree::User` there is `ship_address_id` and `bill_address_id` columns which indicates which addresses are the default ones for this User.
## Checkout
diff --git a/guides/src/content/developer/core/adjustments.md b/guides/src/content/developer/core/adjustments.md
index efc81b2f69..31095df5b1 100644
--- a/guides/src/content/developer/core/adjustments.md
+++ b/guides/src/content/developer/core/adjustments.md
@@ -1,6 +1,7 @@
---
title: "Adjustments"
section: core
+order: 6
---
## Overview
diff --git a/guides/src/content/developer/core/calculators.md b/guides/src/content/developer/core/calculators.md
index 41ff6e50a3..d0fd490e50 100644
--- a/guides/src/content/developer/core/calculators.md
+++ b/guides/src/content/developer/core/calculators.md
@@ -1,6 +1,7 @@
---
title: 'Calculators'
section: core
+order: 7
---
## Overview
diff --git a/guides/src/content/developer/core/index.md b/guides/src/content/developer/core/index.md
new file mode 100644
index 0000000000..67c1a212e0
--- /dev/null
+++ b/guides/src/content/developer/core/index.md
@@ -0,0 +1,9 @@
+---
+title: "Spree Core"
+section: core
+---
+
+This section covers all of the most important Spree internals. Nitty-gritty technical descriptions of how Spree works under the hood.
+
+To understand articles in this section you need to have at least basic Ruby on Rails knoledge. We recommend you
+make yourself acquainted with [Rails Guides](https://guides.rubyonrails.org/index.html).
diff --git a/guides/src/content/developer/core/inventory.md b/guides/src/content/developer/core/inventory.md
index bedd9b1c94..83de29c0a3 100644
--- a/guides/src/content/developer/core/inventory.md
+++ b/guides/src/content/developer/core/inventory.md
@@ -1,6 +1,7 @@
---
title: "Inventory"
section: core
+order: 5
---
## Overview
diff --git a/guides/src/content/developer/core/orders.md b/guides/src/content/developer/core/orders.md
index 14113911ac..90a4b06838 100644
--- a/guides/src/content/developer/core/orders.md
+++ b/guides/src/content/developer/core/orders.md
@@ -1,6 +1,7 @@
---
title: "Orders"
section: core
+order: 1
---
## Overview
@@ -99,7 +100,7 @@ For more on this please go to [Payment States page](/developer/core/payments.htm
## Line Items
-Line items are used to keep track of items within the context of an order. These records provide a link between orders, and [Variants](products#variants).
+Line items are used to keep track of items within the context of an order. These records provide a link between orders, and [Variants](products.html#variants).
When a variant is added to an order, the price of that item is tracked along with the line item to preserve that data. If the variant's price were to change, then the line item would still have a record of the price at the time of ordering.
diff --git a/guides/src/content/developer/core/payments.md b/guides/src/content/developer/core/payments.md
index e154e5d746..1ea0df14f7 100644
--- a/guides/src/content/developer/core/payments.md
+++ b/guides/src/content/developer/core/payments.md
@@ -1,6 +1,7 @@
---
title: "Payments"
section: core
+order: 3
---
## Overview
diff --git a/guides/src/content/developer/core/products.md b/guides/src/content/developer/core/products.md
index 5dc4ff698a..b7d17a4c28 100644
--- a/guides/src/content/developer/core/products.md
+++ b/guides/src/content/developer/core/products.md
@@ -1,6 +1,7 @@
---
title: "Products"
section: core
+order: 2
---
## Overview
diff --git a/guides/src/content/developer/core/promotions.md b/guides/src/content/developer/core/promotions.md
index 8ae4d0a697..1426d3534f 100644
--- a/guides/src/content/developer/core/promotions.md
+++ b/guides/src/content/developer/core/promotions.md
@@ -1,6 +1,7 @@
---
title: "Promotions"
section: core
+order: 5
---
## Overview
diff --git a/guides/src/content/developer/core/shipments.md b/guides/src/content/developer/core/shipments.md
index 57e11f43bb..20cdb59375 100644
--- a/guides/src/content/developer/core/shipments.md
+++ b/guides/src/content/developer/core/shipments.md
@@ -1,6 +1,7 @@
---
title: "Shipments"
section: "core"
+order: 4
---
## Overview
diff --git a/guides/src/content/developer/core/stores.md b/guides/src/content/developer/core/stores.md
new file mode 100644
index 0000000000..7e374aebf5
--- /dev/null
+++ b/guides/src/content/developer/core/stores.md
@@ -0,0 +1,84 @@
+---
+title: "Stores"
+section: core
+order: 0
+---
+
+<alert kind="note">
+ This section only applies to Spree 4.2 or newer. If you're using an older version, [please upgrade](/developer/upgrades)
+</alert>
+
+## Overview
+
+The `Store` model is the center of the Spree ecosystem. Each Spree installation can have multiple Stores.
+Each Store operates on a different domain or subdomain, eg.
+
+* Store A, `us.example.com`
+* Store B, `eu.example.com`
+* Store C, `another-brand.com`
+
+## `current_store` method
+
+All Spree controllers or any other controllers that includes [Spree::Core::ControllerHelpers::Store](https://github.com/spree/spree/blob/master/core/lib/spree/core/controller_helpers/store.rb) have access to the `current_store` method which returns the currently in use `Spree::Store` object.
+All parts of Spree (API v1, API v2, Storefront, Admin Panel) include this mechanism. This method is also available in views.
+
+Under the hood `current_store` calls [Store.current](https://github.com/spree/spree/blob/master/core/app/models/spree/store.rb#L36).
+
+## Default Store
+
+If the system cannot find any Store that matches the current URL it will fallback to the Default Store.
+
+You can set the default Store in Admin Panel -> Configurations -> Store.
+
+To get the default store in code you can call `Spree::Store.default`.
+
+## Localization and Currency
+
+Each Store can have different multiple locales and currencies. This configuration is stored in Store model attributes:
+
+* `default_currency`- this is the default currency this is the default locale/language which will be pre-selected when visiting the store the first time, eg. `USD`
+* `supported_currencies` - if there are more than one supported currency visitor will be able to choose which currency they would like to browse your store, eg. `USD,CAD`
+* `default_locale` - this is the default locale/language which will be pre-selected when visiting the store the first time, eg. `en`
+* `supported_locales`, if there are more than one supported locale visitor will be able to choose which locale they would like to browse your store, eg `en,fr`. Locales are available upon installing [Spree I18n](https://github.com/spree-contrib/spree_i18n)
+
+## Checkout configuration
+
+Each Store can be configured to ship to only selected countries. This is achieved via `checkout_zone_id` attribute which holds the ID of the selected [Zone record](/user/configuration/configuring_geography.html).
+
+Available Shipping Methods on the Checkout are determined based on the [Zone and Shipping Methods configuration](/developer/core/shipments.html).
+
+This will also have an effect on what [Shipping / Billing Addresses](/developer/core/addresses.html) user can add / select during Checkout. Only Addresses from Countries or States available in the selected Zone can be used and will be visible in the User's Address Book.
+
+## Associated models
+
+### Orders
+
+When a user starts a checkout in a selected Store [Order](/developer/core/orders.html) is associated with that Store. That means that items added to the Cart will be visible only in a selected Store. If a user switches to another Store they will have a separate `Order` record for that Store. Order is created when a User adds the first item to the Cart. This means you can host multiple brands on one single Spree instance.
+
+### Payment Methods
+
+Each [Payment Method](/developer/core/payments.html#payment-methods) can be associated with multiple Stores, eg. you would like to have Stripe and PayPal in Store A, but only Stripe in Store B, and Braintree in Store C.
+
+### Products
+
+There's no direct association between Stores and Products in Spree Core, however which Products are available in which Store is determined on the selected currency. If Product A has prices in `USD` and `EUR` it will be available for purchase in all Stores that support that currency.
+
+If you would like to have more granual level control of Products availability in Stores you can install [Spree Multi Domain extension](https://github.com/spree-contrib/spree-multi-domain). It lets you choose Stores for Products. That extension will be pulled into Spree Core in Soree 4.3.
+
+## Store layout
+
+<alert kind="note">
+ This feature is only available with [Spree Multi Domain extension](https://github.com/spree-contrib/spree-multi-domain) at the moment but will be included in Spree Core in 4.3 release.
+</alert>
+
+<alert kind="note">
+ This is only applicable to Spree default Storefront
+</alert>
+
+Each Store record has a unique attribute called `code`. This an internal name for your Store.
+
+Based on this attribute, each store can have its own layout - these layouts should be located in your site's theme extension in the `app/views/spree/layouts/<store#code>/` directory.
+
+So, if you have a store with a code of `eu` you should store its layout in `app/views/spree/layouts/eu/spree_application.html.erb`.
+
+If there's no custom layout it will fallback to the default one located in `app/views/spree/layouts/spree_application.html.erb`.
diff --git a/guides/src/content/developer/core/taxation.md b/guides/src/content/developer/core/taxation.md
index 2fefb3ec5b..25c0fd9c3c 100644
--- a/guides/src/content/developer/core/taxation.md
+++ b/guides/src/content/developer/core/taxation.md
@@ -1,6 +1,7 @@
---
title: Taxation
section: core
+order: 6
---
## Overview