@spree/docs 0.1.0

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.
Files changed (183) hide show
  1. package/README.md +54 -0
  2. package/dist/api-reference/platform/authentication.md +38 -0
  3. package/dist/api-reference/store-api/authentication.md +188 -0
  4. package/dist/api-reference/store-api/errors.md +277 -0
  5. package/dist/api-reference/store-api/idempotency.md +129 -0
  6. package/dist/api-reference/store-api/introduction.md +34 -0
  7. package/dist/api-reference/store-api/localization.md +279 -0
  8. package/dist/api-reference/store-api/metadata.md +160 -0
  9. package/dist/api-reference/store-api/monetary-amounts.md +65 -0
  10. package/dist/api-reference/store-api/querying.md +399 -0
  11. package/dist/api-reference/store-api/rate-limitting.md +103 -0
  12. package/dist/api-reference/store-api/relations.md +185 -0
  13. package/dist/api-reference/storefront/authentication.md +88 -0
  14. package/dist/api-reference/tutorials/adyen-integration-guide-for-android.md +165 -0
  15. package/dist/api-reference/tutorials/adyen-integration-guide-for-ios.md +194 -0
  16. package/dist/api-reference/tutorials/quick-checkout-with-stripe.md +248 -0
  17. package/dist/api-reference/v2/fetching-multiple-resources.md +26 -0
  18. package/dist/api-reference/v2/filtering-and-sorting.md +53 -0
  19. package/dist/api-reference/v2/introduction.md +22 -0
  20. package/dist/api-reference/v2/pagination.md +37 -0
  21. package/dist/api-reference/webhooks-events.md +883 -0
  22. package/dist/developer/admin/admin.md +205 -0
  23. package/dist/developer/admin/authentication.md +59 -0
  24. package/dist/developer/admin/components.md +711 -0
  25. package/dist/developer/admin/custom-css.md +243 -0
  26. package/dist/developer/admin/custom-javascript.md +116 -0
  27. package/dist/developer/admin/extending-ui.md +1964 -0
  28. package/dist/developer/admin/form-builder.md +444 -0
  29. package/dist/developer/admin/helper-methods.md +531 -0
  30. package/dist/developer/admin/navigation.md +805 -0
  31. package/dist/developer/admin/tables.md +491 -0
  32. package/dist/developer/advanced/adding_spree_to_rails_app.md +106 -0
  33. package/dist/developer/cli/quickstart.md +137 -0
  34. package/dist/developer/contributing/creating-an-extension.md +258 -0
  35. package/dist/developer/contributing/developing-spree.md +339 -0
  36. package/dist/developer/contributing/quickstart.md +32 -0
  37. package/dist/developer/contributing/updating-extensions.md +67 -0
  38. package/dist/developer/core-concepts/addresses.md +265 -0
  39. package/dist/developer/core-concepts/adjustments.md +107 -0
  40. package/dist/developer/core-concepts/architecture.md +177 -0
  41. package/dist/developer/core-concepts/calculators.md +323 -0
  42. package/dist/developer/core-concepts/customers.md +230 -0
  43. package/dist/developer/core-concepts/events.md +624 -0
  44. package/dist/developer/core-concepts/imports-exports.md +698 -0
  45. package/dist/developer/core-concepts/inventory.md +191 -0
  46. package/dist/developer/core-concepts/markets.md +250 -0
  47. package/dist/developer/core-concepts/media.md +167 -0
  48. package/dist/developer/core-concepts/metafields.md +187 -0
  49. package/dist/developer/core-concepts/orders.md +328 -0
  50. package/dist/developer/core-concepts/payments.md +710 -0
  51. package/dist/developer/core-concepts/pricing.md +163 -0
  52. package/dist/developer/core-concepts/products.md +360 -0
  53. package/dist/developer/core-concepts/promotions.md +322 -0
  54. package/dist/developer/core-concepts/reports.md +206 -0
  55. package/dist/developer/core-concepts/search-filtering.md +237 -0
  56. package/dist/developer/core-concepts/shipments.md +212 -0
  57. package/dist/developer/core-concepts/slugs.md +111 -0
  58. package/dist/developer/core-concepts/staff-roles.md +123 -0
  59. package/dist/developer/core-concepts/store-credits-gift-cards.md +317 -0
  60. package/dist/developer/core-concepts/stores.md +117 -0
  61. package/dist/developer/core-concepts/taxes.md +135 -0
  62. package/dist/developer/core-concepts/translations.md +120 -0
  63. package/dist/developer/core-concepts/users.md +299 -0
  64. package/dist/developer/core-concepts/webhooks.md +378 -0
  65. package/dist/developer/create-spree-app/quickstart.md +158 -0
  66. package/dist/developer/customization/api.md +93 -0
  67. package/dist/developer/customization/authentication.md +88 -0
  68. package/dist/developer/customization/checkout.md +204 -0
  69. package/dist/developer/customization/configuration.md +55 -0
  70. package/dist/developer/customization/decorators.md +523 -0
  71. package/dist/developer/customization/dependencies.md +232 -0
  72. package/dist/developer/customization/emails.md +21 -0
  73. package/dist/developer/customization/extensions.md +92 -0
  74. package/dist/developer/customization/metadata.md +236 -0
  75. package/dist/developer/customization/model-preferences.md +130 -0
  76. package/dist/developer/customization/permissions.md +265 -0
  77. package/dist/developer/customization/quickstart.md +229 -0
  78. package/dist/developer/customization/routes.md +24 -0
  79. package/dist/developer/customization/v4/admin-panel.md +78 -0
  80. package/dist/developer/customization/v4/authentication.md +210 -0
  81. package/dist/developer/customization/v4/checkout.md +212 -0
  82. package/dist/developer/customization/v4/deface.md +251 -0
  83. package/dist/developer/customization/v4/images.md +86 -0
  84. package/dist/developer/customization/v4/storefront.md +450 -0
  85. package/dist/developer/deployment/assets.md +87 -0
  86. package/dist/developer/deployment/aws.md +335 -0
  87. package/dist/developer/deployment/caching.md +27 -0
  88. package/dist/developer/deployment/cdn.md +39 -0
  89. package/dist/developer/deployment/database.md +155 -0
  90. package/dist/developer/deployment/docker.md +128 -0
  91. package/dist/developer/deployment/emails.md +77 -0
  92. package/dist/developer/deployment/environment_variables.md +111 -0
  93. package/dist/developer/deployment/heroku.md +51 -0
  94. package/dist/developer/deployment/render.md +95 -0
  95. package/dist/developer/getting-started/quickstart.md +82 -0
  96. package/dist/developer/how-to/custom-payment-method.md +374 -0
  97. package/dist/developer/how-to/custom-promotion.md +373 -0
  98. package/dist/developer/how-to/custom-report.md +387 -0
  99. package/dist/developer/how-to/custom-search-provider.md +230 -0
  100. package/dist/developer/multi-store/quickstart.md +71 -0
  101. package/dist/developer/multi-store/setup.md +38 -0
  102. package/dist/developer/multi-tenant/configuration.md +41 -0
  103. package/dist/developer/multi-tenant/core-concepts.md +75 -0
  104. package/dist/developer/multi-tenant/installation.md +96 -0
  105. package/dist/developer/multi-tenant/quickstart.md +20 -0
  106. package/dist/developer/multi-vendor/installation.md +45 -0
  107. package/dist/developer/multi-vendor/quickstart.md +17 -0
  108. package/dist/developer/sdk/admin/quickstart.md +22 -0
  109. package/dist/developer/sdk/authentication.md +89 -0
  110. package/dist/developer/sdk/configuration.md +225 -0
  111. package/dist/developer/sdk/quickstart.md +82 -0
  112. package/dist/developer/sdk/store/account.md +67 -0
  113. package/dist/developer/sdk/store/cart-checkout.md +140 -0
  114. package/dist/developer/sdk/store/markets.md +151 -0
  115. package/dist/developer/sdk/store/payments.md +96 -0
  116. package/dist/developer/sdk/store/products.md +149 -0
  117. package/dist/developer/sdk/store/wishlists.md +52 -0
  118. package/dist/developer/security/pci_compliance.md +15 -0
  119. package/dist/developer/security/security_policy.md +68 -0
  120. package/dist/developer/storefront/blocks.md +285 -0
  121. package/dist/developer/storefront/custom-css.md +260 -0
  122. package/dist/developer/storefront/custom-javascript.md +166 -0
  123. package/dist/developer/storefront/helper-methods.md +1288 -0
  124. package/dist/developer/storefront/links.md +298 -0
  125. package/dist/developer/storefront/nextjs/architecture.md +150 -0
  126. package/dist/developer/storefront/nextjs/customization.md +141 -0
  127. package/dist/developer/storefront/nextjs/deployment.md +180 -0
  128. package/dist/developer/storefront/nextjs/quickstart.md +92 -0
  129. package/dist/developer/storefront/nextjs/spree-next-package.md +314 -0
  130. package/dist/developer/storefront/pages.md +163 -0
  131. package/dist/developer/storefront/sections.md +569 -0
  132. package/dist/developer/storefront/storefront.md +56 -0
  133. package/dist/developer/storefront/themes.md +161 -0
  134. package/dist/developer/tutorial/admin.md +134 -0
  135. package/dist/developer/tutorial/extending-models.md +380 -0
  136. package/dist/developer/tutorial/file-uploads.md +121 -0
  137. package/dist/developer/tutorial/introduction.md +33 -0
  138. package/dist/developer/tutorial/model.md +41 -0
  139. package/dist/developer/tutorial/page-builder.md +487 -0
  140. package/dist/developer/tutorial/rich-text.md +73 -0
  141. package/dist/developer/tutorial/seo.md +332 -0
  142. package/dist/developer/tutorial/storefront.md +352 -0
  143. package/dist/developer/tutorial/testing.md +558 -0
  144. package/dist/developer/upgrades/2.0-to-2.1.md +46 -0
  145. package/dist/developer/upgrades/2.1-to-2.2.md +59 -0
  146. package/dist/developer/upgrades/2.2-to-2.3.md +44 -0
  147. package/dist/developer/upgrades/2.3-to-2.4.md +42 -0
  148. package/dist/developer/upgrades/3.0-to-3.1.md +47 -0
  149. package/dist/developer/upgrades/3.1-to-3.2.md +34 -0
  150. package/dist/developer/upgrades/3.2-to-3.3.md +70 -0
  151. package/dist/developer/upgrades/3.3-to-3.4.md +36 -0
  152. package/dist/developer/upgrades/3.4-to-3.5.md +44 -0
  153. package/dist/developer/upgrades/3.5-to-3.6.md +40 -0
  154. package/dist/developer/upgrades/3.6-to-3.7.md +62 -0
  155. package/dist/developer/upgrades/3.7-to-4.0.md +152 -0
  156. package/dist/developer/upgrades/4.0-to-4.1.md +92 -0
  157. package/dist/developer/upgrades/4.1-to-4.2.md +109 -0
  158. package/dist/developer/upgrades/4.10-to-5.0.md +129 -0
  159. package/dist/developer/upgrades/4.2-to-4.3.md +100 -0
  160. package/dist/developer/upgrades/4.3-to-4.4.md +125 -0
  161. package/dist/developer/upgrades/4.4-to-4.5.md +94 -0
  162. package/dist/developer/upgrades/4.5-to-4.6.md +119 -0
  163. package/dist/developer/upgrades/4.6-to-4.7.md +39 -0
  164. package/dist/developer/upgrades/4.8-to-4.9.md +24 -0
  165. package/dist/developer/upgrades/4.9-to-4.10.md +24 -0
  166. package/dist/developer/upgrades/4.x-to-4.8.md +52 -0
  167. package/dist/developer/upgrades/5.0-to-5.1.md +28 -0
  168. package/dist/developer/upgrades/5.1-to-5.2.md +127 -0
  169. package/dist/developer/upgrades/5.2-to-5.3.md +338 -0
  170. package/dist/developer/upgrades/5.3-to-5.4.md +248 -0
  171. package/dist/developer/upgrades/quickstart.md +36 -0
  172. package/dist/integrations/analytics/google-analytics.md +64 -0
  173. package/dist/integrations/analytics/google-tag-manager.md +78 -0
  174. package/dist/integrations/integrations.md +39 -0
  175. package/dist/integrations/marketing/klaviyo.md +99 -0
  176. package/dist/integrations/payments/adyen.md +90 -0
  177. package/dist/integrations/payments/paypal.md +41 -0
  178. package/dist/integrations/payments/razorpay.md +45 -0
  179. package/dist/integrations/payments/stripe.md +109 -0
  180. package/dist/integrations/search/meilisearch.md +236 -0
  181. package/dist/integrations/sso-mfa-social-login/admin-dashboard.md +57 -0
  182. package/dist/integrations/sso-mfa-social-login/storefront.md +56 -0
  183. package/package.json +27 -0
@@ -0,0 +1,187 @@
1
+ ---
2
+ title: Metafields
3
+ description: Add custom structured data to products, orders, and other resources with type-safe metafields
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Metafields provide a flexible, type-safe system for adding custom structured data to Spree resources. Unlike [metadata](/developer/customization/metadata) which is simple JSON storage, metafields are schema-defined with strong typing, validation, and visibility controls.
9
+
10
+ Use metafields for:
11
+
12
+ - Product specifications (manufacturer, material, dimensions)
13
+ - Custom business logic fields
14
+ - Integration data from external systems
15
+ - Order-specific custom attributes
16
+
17
+ > **NOTE:** Metafields are available from Spree 5.2 onwards.
18
+
19
+ ## Architecture
20
+
21
+ ```mermaid
22
+ erDiagram
23
+ MetafieldDefinition ||--o{ Metafield : "defines schema for"
24
+ Product ||--o{ Metafield : "has many"
25
+ Variant ||--o{ Metafield : "has many"
26
+ Order ||--o{ Metafield : "has many"
27
+
28
+ MetafieldDefinition {
29
+ string namespace
30
+ string key
31
+ string name
32
+ string metafield_type
33
+ string resource_type
34
+ string display_on
35
+ }
36
+
37
+ Metafield {
38
+ string type
39
+ text value
40
+ string resource_type
41
+ }
42
+ ```
43
+
44
+ ```mermaid
45
+ flowchart LR
46
+ subgraph Definition
47
+ A[MetafieldDefinition] --> B["namespace: properties"]
48
+ A --> C["key: manufacturer"]
49
+ A --> D["type: ShortText"]
50
+ A --> E["resource_type: Product"]
51
+ A --> F["display_on: both"]
52
+ end
53
+
54
+ subgraph Instance
55
+ G[Metafield] --> H["value: Wilson"]
56
+ G --> I["resource: Product #1"]
57
+ end
58
+
59
+ A -.->|"defines schema"| G
60
+ ```
61
+
62
+ - **MetafieldDefinition** — the blueprint that defines the data type, target resource, and visibility
63
+ - **Metafield** — stores the actual value for a specific resource instance
64
+
65
+ ## Data Types
66
+
67
+ | Type | Description | Example Values |
68
+ |------|-------------|----------------|
69
+ | Short Text | Brief text fields | SKU codes, brand names, tags |
70
+ | Long Text | Longer text content | Care instructions, notes |
71
+ | Rich Text | Formatted HTML content | Product descriptions with formatting |
72
+ | Number | Numeric values | Weight, quantity, ratings |
73
+ | Boolean | True/false flags | Is featured, requires signature |
74
+ | JSON | Structured data | Configuration, complex objects |
75
+
76
+ ## Visibility Control
77
+
78
+ Metafields support three visibility levels via the `display_on` attribute:
79
+
80
+ | Visibility | Store API | Admin API | Use Case |
81
+ |------------|:---------:|:---------:|----------|
82
+ | `both` | Yes | Yes | Public product specifications |
83
+ | `front_end` | Yes | No | Customer-facing data |
84
+ | `back_end` | No | Yes | Internal notes, integration IDs |
85
+
86
+ ## Supported Resources
87
+
88
+ Metafields can be attached to most Spree resources including Products, Variants, Orders, Line Items, Taxons, Payments, Shipments, Gift Cards, Store Credits, and more.
89
+
90
+ > **INFO:** Custom resources can also support metafields. See the [Customization Quickstart](/developer/customization/quickstart) for details.
91
+
92
+ ## Namespaces
93
+
94
+ Namespaces organize metafields into logical groups and prevent key conflicts:
95
+
96
+ | Namespace | Example Keys | Purpose |
97
+ |-----------|-------------|---------|
98
+ | `properties` | `manufacturer`, `material`, `fit` | Product specifications |
99
+ | `shopify` | `product_id`, `variant_id` | Integration data |
100
+ | `flags` | `featured`, `requires_approval` | Feature flags |
101
+ | `custom` | `gift_message`, `delivery_notes` | Business-specific fields |
102
+
103
+ > **INFO:** Namespace and key are automatically normalized to snake_case.
104
+
105
+ ## Store API
106
+
107
+ Metafields with `display_on` set to `both` or `front_end` are included in Store API responses when you request the `metafields` expand:
108
+
109
+
110
+ ```typescript SDK
111
+ const product = await client.products.get('spree-tote', {
112
+ expand: ['metafields'],
113
+ })
114
+
115
+ product.metafields?.forEach(metafield => {
116
+ console.log(metafield.key) // "properties.manufacturer"
117
+ console.log(metafield.name) // "Manufacturer"
118
+ console.log(metafield.value) // "Wilson"
119
+ console.log(metafield.type) // "short_text"
120
+ })
121
+ ```
122
+
123
+ ```bash cURL
124
+ curl 'https://api.mystore.com/api/v3/store/products/spree-tote?expand=metafields' \
125
+ -H 'Authorization: Bearer spree_pk_xxx'
126
+ ```
127
+
128
+
129
+ **Response:**
130
+
131
+ ```json
132
+ {
133
+ "id": "prod_86Rf07xd4z",
134
+ "name": "Spree T-Shirt",
135
+ "metafields": [
136
+ {
137
+ "id": "mf_k5nR8xLq",
138
+ "name": "Manufacturer",
139
+ "key": "properties.manufacturer",
140
+ "type": "short_text",
141
+ "value": "Wilson"
142
+ },
143
+ {
144
+ "id": "mf_m3Rp9wXz",
145
+ "name": "Material",
146
+ "key": "properties.material",
147
+ "type": "short_text",
148
+ "value": "100% Cotton"
149
+ }
150
+ ]
151
+ }
152
+ ```
153
+
154
+ > **NOTE:** The `display_on` attribute is intentionally excluded from Store API responses for security.
155
+
156
+ ## Admin Panel Management
157
+
158
+ ### Managing Definitions
159
+
160
+ Navigate to **Settings → Metafield Definitions** in the Admin Panel to create and manage metafield definitions. Select the resource type, enter namespace and key, choose the data type, and set visibility.
161
+
162
+ ### Managing Values
163
+
164
+ When editing a resource (e.g., a product), metafields appear in a dedicated section. The admin panel automatically builds forms for all defined metafields.
165
+
166
+ ## Metafields vs Metadata
167
+
168
+ | Feature | Metafields | Metadata |
169
+ |---------|-----------|----------|
170
+ | Structure | Strongly typed, schema-defined | Flat key-value JSON |
171
+ | Validation | Type-specific validation | None |
172
+ | Visibility | Configurable (front/back/both) | Write-only in Store API |
173
+ | Admin UI | Dedicated management forms | JSON preview |
174
+ | Data Types | 6 specific types | Any JSON-serializable data |
175
+ | Organization | Namespaced (`namespace.key`) | Flat structure |
176
+
177
+ **Use Metafields** when you need type validation, visibility control, admin UI forms, or organized namespacing.
178
+
179
+ **Use Metadata** for external system IDs, tracking attribution, or simple write-and-forget data.
180
+
181
+ > **WARNING:** Product Properties are deprecated and will be removed in Spree 6.0. For new projects, always use Metafields. For existing projects, plan to migrate using the [migration guide](/developer/upgrades/5.1-to-5.2#3-migrate-to-metafields-or-keep-using-properties).
182
+
183
+ ## Related Documentation
184
+
185
+ - [Metadata](/developer/customization/metadata) — Simple key-value metadata
186
+ - [Products](/developer/core-concepts/products) — Product catalog
187
+ - [Events](/developer/core-concepts/events) — Subscribe to metafield events
@@ -0,0 +1,328 @@
1
+ ---
2
+ title: Orders
3
+ description: Order lifecycle, checkout flow, line items, payments, and shipments
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ An order is the central model connecting a customer to their purchase. It collects line items, addresses, shipments, payments, and adjustments into a single transaction that flows through a checkout state machine from cart to completion.
9
+
10
+ ```mermaid
11
+ erDiagram
12
+ Order ||--o{ LineItem : "has many"
13
+ Order ||--o{ Shipment : "has many"
14
+ Order ||--o{ Payment : "has many"
15
+ Order ||--o{ Adjustment : "has many"
16
+ Order }o--|| Address : "ship_address"
17
+ Order }o--|| Address : "bill_address"
18
+ Order }o--|| User : "belongs to"
19
+ Order }o--|| Store : "belongs to"
20
+ LineItem }o--|| Variant : "belongs to"
21
+ Shipment }o--|| StockLocation : "ships from"
22
+ Payment }o--|| PaymentMethod : "belongs to"
23
+
24
+ Order {
25
+ string number
26
+ string state
27
+ string email
28
+ string currency
29
+ decimal total
30
+ string payment_state
31
+ string shipment_state
32
+ }
33
+
34
+ LineItem {
35
+ integer quantity
36
+ decimal price
37
+ }
38
+
39
+ Shipment {
40
+ string number
41
+ string state
42
+ string tracking
43
+ }
44
+
45
+ Payment {
46
+ decimal amount
47
+ string state
48
+ }
49
+ ```
50
+
51
+ **Key relationships:**
52
+ - **Line Items** link orders to [Variants](/developer/core-concepts/products#variants) (what was purchased)
53
+ - **[Shipments](/developer/core-concepts/shipments)** handle fulfillment from stock locations
54
+ - **[Payments](/developer/core-concepts/payments)** track payment attempts and their states
55
+ - **[Adjustments](/developer/core-concepts/adjustments)** apply taxes, promotions, and shipping costs
56
+ - **[Addresses](/developer/core-concepts/addresses)** store billing and shipping information
57
+
58
+ ## Order Attributes
59
+
60
+ The API returns these key fields on every order:
61
+
62
+ | Attribute | Description |
63
+ |-----------|-------------|
64
+ | `number` | Unique order number (e.g., `R123456789`), shown to customers |
65
+ | `state` | Current checkout state (`cart`, `address`, `delivery`, `payment`, `confirm`, `complete`) |
66
+ | `email` | Customer's email address |
67
+ | `currency` | Order currency (e.g., `USD`) |
68
+ | `item_count` | Total number of items |
69
+ | `item_total` / `display_item_total` | Sum of line item prices |
70
+ | `ship_total` / `display_ship_total` | Shipping cost |
71
+ | `tax_total` / `display_tax_total` | Total tax |
72
+ | `promo_total` / `display_promo_total` | Total discount from promotions |
73
+ | `adjustment_total` / `display_adjustment_total` | Sum of all adjustments (tax + shipping + promos) |
74
+ | `total` / `display_total` | Final order total |
75
+ | `payment_state` | Payment status (`balance_due`, `paid`, `credit_owed`, `failed`, `void`) |
76
+ | `shipment_state` | Shipment status (`pending`, `ready`, `partial`, `shipped`, `backorder`) |
77
+ | `completed_at` | Timestamp when the order was placed |
78
+
79
+ The `display_*` fields return formatted strings with currency symbols (e.g., `"$15.99"`).
80
+
81
+ ## Cart
82
+
83
+ A cart is simply an order in the `cart` state. Guest carts are identified by a cart token; authenticated users' carts are linked to their account.
84
+
85
+
86
+ ```typescript SDK
87
+ // Create a cart
88
+ const cart = await client.carts.create()
89
+ // cart.token => "abc123" (save this for guest checkout)
90
+
91
+ // Get existing cart
92
+ const cart = await client.carts.get(cartId, { spreeToken: 'xxx' })
93
+
94
+ // Add an item
95
+ const updatedOrder = await client.carts.items.create(cart.id, {
96
+ variant_id: 'var_xxx',
97
+ quantity: 2,
98
+ })
99
+
100
+ // Update quantity
101
+ await client.carts.items.update(cart.id, 'li_xxx', {
102
+ quantity: 3,
103
+ })
104
+
105
+ // Remove an item
106
+ await client.carts.items.delete(cart.id, 'li_xxx')
107
+ ```
108
+
109
+ ```bash cURL
110
+ # Create a cart
111
+ curl -X POST 'https://api.mystore.com/api/v3/store/carts' \
112
+ -H 'Authorization: Bearer spree_pk_xxx'
113
+
114
+ # Get existing cart
115
+ curl 'https://api.mystore.com/api/v3/store/carts/cart_xxx' \
116
+ -H 'Authorization: Bearer spree_pk_xxx' \
117
+ -H 'X-Spree-Token: abc123'
118
+
119
+ # Add an item
120
+ curl -X POST 'https://api.mystore.com/api/v3/store/carts/cart_xxx/items' \
121
+ -H 'Authorization: Bearer spree_pk_xxx' \
122
+ -H 'X-Spree-Token: abc123' \
123
+ -H 'Content-Type: application/json' \
124
+ -d '{ "variant_id": "var_xxx", "quantity": 2 }'
125
+
126
+ # Update quantity
127
+ curl -X PATCH 'https://api.mystore.com/api/v3/store/carts/cart_xxx/items/li_xxx' \
128
+ -H 'Authorization: Bearer spree_pk_xxx' \
129
+ -H 'X-Spree-Token: abc123' \
130
+ -H 'Content-Type: application/json' \
131
+ -d '{ "quantity": 3 }'
132
+
133
+ # Remove an item
134
+ curl -X DELETE 'https://api.mystore.com/api/v3/store/carts/cart_xxx/items/li_xxx' \
135
+ -H 'Authorization: Bearer spree_pk_xxx' \
136
+ -H 'X-Spree-Token: abc123'
137
+ ```
138
+
139
+
140
+ Every item mutation returns the full updated order with recalculated totals.
141
+
142
+ ## Checkout Flow
143
+
144
+ The checkout is a state machine that advances the order through a series of steps. Each step collects required information before allowing the order to proceed.
145
+
146
+ **Step 1: cart**
147
+
148
+ Customer has items in their cart. This is the starting state.
149
+
150
+ **Step 2: address**
151
+
152
+ Customer provides shipping and billing addresses.
153
+
154
+ **Step 3: delivery**
155
+
156
+ Customer selects a shipping rate for each shipment.
157
+
158
+ **Step 4: payment**
159
+
160
+ Customer provides payment. Skipped if the order is fully covered by store credit.
161
+
162
+ **Step 5: confirm**
163
+
164
+ Customer reviews and confirms the order.
165
+
166
+ **Step 6: complete**
167
+
168
+ Order is placed. `completed_at` is set and fulfillment begins.
169
+
170
+
171
+ If the order doesn't meet the requirements for the next state (e.g., missing address), the API returns an error.
172
+
173
+
174
+ ```typescript SDK
175
+ // Set addresses
176
+ await client.carts.update(cartId, {
177
+ email: 'john@example.com',
178
+ ship_address: {
179
+ firstname: 'John', lastname: 'Doe',
180
+ address1: '123 Main St', city: 'Los Angeles',
181
+ country_iso: 'US', state_abbr: 'CA', zipcode: '90001',
182
+ phone: '555-0100',
183
+ },
184
+ })
185
+
186
+ // Get shipments and select a shipping rate
187
+ const { data: shipments } = await client.carts.shipments.list(cartId)
188
+ await client.carts.shipments.update(cartId, shipments[0].id, {
189
+ selected_shipping_rate_id: 'sr_xxx',
190
+ })
191
+
192
+ // Create a payment session (e.g., Stripe)
193
+ const session = await client.carts.paymentSessions.create(cartId, {
194
+ payment_method_id: 'pm_xxx',
195
+ })
196
+ // session.external_data.client_secret => use with Stripe.js
197
+
198
+ // Complete the payment session after provider confirmation
199
+ await client.carts.paymentSessions.complete(cartId, session.id)
200
+
201
+ // Complete the order
202
+ await client.carts.complete(cartId)
203
+ ```
204
+
205
+ ```bash cURL
206
+ # Set addresses
207
+ curl -X PATCH 'https://api.mystore.com/api/v3/store/carts/cart_xxx' \
208
+ -H 'Authorization: Bearer spree_pk_xxx' \
209
+ -H 'X-Spree-Token: abc123' \
210
+ -H 'Content-Type: application/json' \
211
+ -d '{
212
+ "email": "john@example.com",
213
+ "ship_address": {
214
+ "firstname": "John", "lastname": "Doe",
215
+ "address1": "123 Main St", "city": "Los Angeles",
216
+ "country_iso": "US", "state_abbr": "CA", "zipcode": "90001",
217
+ "phone": "555-0100"
218
+ }
219
+ }'
220
+
221
+ # Select a shipping rate
222
+ curl -X PATCH 'https://api.mystore.com/api/v3/store/carts/cart_xxx/shipments/shp_xxx' \
223
+ -H 'Authorization: Bearer spree_pk_xxx' \
224
+ -H 'X-Spree-Token: abc123' \
225
+ -H 'Content-Type: application/json' \
226
+ -d '{ "selected_shipping_rate_id": "sr_xxx" }'
227
+
228
+ # Complete the order
229
+ curl -X POST 'https://api.mystore.com/api/v3/store/carts/cart_xxx/complete' \
230
+ -H 'Authorization: Bearer spree_pk_xxx' \
231
+ -H 'X-Spree-Token: abc123'
232
+ ```
233
+
234
+
235
+ ## Coupon Codes
236
+
237
+ Apply or remove promotional coupon codes during checkout:
238
+
239
+
240
+ ```typescript SDK
241
+ // Apply a coupon
242
+ await client.carts.couponCodes.apply(cartId, 'SAVE20')
243
+
244
+ // Remove a coupon
245
+ await client.carts.couponCodes.remove(cartId, 'SAVE20')
246
+ ```
247
+
248
+ ```bash cURL
249
+ # Apply a coupon
250
+ curl -X POST 'https://api.mystore.com/api/v3/store/carts/cart_xxx/coupon_codes' \
251
+ -H 'Authorization: Bearer spree_pk_xxx' \
252
+ -H 'X-Spree-Token: abc123' \
253
+ -H 'Content-Type: application/json' \
254
+ -d '{ "code": "SAVE20" }'
255
+
256
+ # Remove a coupon
257
+ curl -X DELETE 'https://api.mystore.com/api/v3/store/carts/cart_xxx/coupon_codes/SAVE20' \
258
+ -H 'Authorization: Bearer spree_pk_xxx' \
259
+ -H 'X-Spree-Token: abc123'
260
+ ```
261
+
262
+
263
+ ## Order History
264
+
265
+ Authenticated customers can view their past orders:
266
+
267
+
268
+ ```typescript SDK
269
+ // List past orders
270
+ const { data: orders } = await client.customer.orders.list()
271
+
272
+ // Get a specific order with details
273
+ const order = await client.orders.get('or_xxx', {
274
+ expand: ['items', 'shipments', 'payments'],
275
+ })
276
+ ```
277
+
278
+ ```bash cURL
279
+ # List past orders
280
+ curl 'https://api.mystore.com/api/v3/store/customer/orders' \
281
+ -H 'Authorization: Bearer <jwt_token>'
282
+
283
+ # Get a specific order
284
+ curl 'https://api.mystore.com/api/v3/store/orders/or_xxx?expand=items,shipments,payments' \
285
+ -H 'Authorization: Bearer <jwt_token>'
286
+ ```
287
+
288
+
289
+ ## Line Items
290
+
291
+ Line items represent individual products in an order. Each line item links to a [Variant](/developer/core-concepts/products#variants) and tracks the quantity and price at the time of purchase.
292
+
293
+ When a variant is added to an order, the price is locked on the line item. If the variant's price changes later, existing orders are unaffected.
294
+
295
+ ## Adjustments
296
+
297
+ [Adjustments](/developer/core-concepts/adjustments) modify an order's total — promotions decrease it, taxes and shipping increase it. Adjustments can be applied at the order level, the line item level, or the shipment level.
298
+
299
+ ## Payment States
300
+
301
+ | State | Description |
302
+ |-------|-------------|
303
+ | `balance_due` | Payment total is less than the order total |
304
+ | `paid` | Payment total equals the order total |
305
+ | `credit_owed` | Payment total exceeds the order total (refund pending) |
306
+ | `failed` | Most recent payment attempt failed |
307
+ | `void` | Order was canceled and payments voided |
308
+
309
+ ## Shipment States
310
+
311
+ | State | Description |
312
+ |-------|-------------|
313
+ | `pending` | All shipments are pending |
314
+ | `ready` | All shipments are ready to ship |
315
+ | `partial` | At least one shipment is shipped, others are not |
316
+ | `shipped` | All shipments have been shipped |
317
+ | `backorder` | Some inventory is on backorder |
318
+
319
+ For more details, see [Shipments](/developer/core-concepts/shipments) and [Payments](/developer/core-concepts/payments).
320
+
321
+ ## Related Documentation
322
+
323
+ - [Payments](/developer/core-concepts/payments) — Payment processing and payment sessions
324
+ - [Shipments](/developer/core-concepts/shipments) — Fulfillment and shipping rates
325
+ - [Addresses](/developer/core-concepts/addresses) — Billing and shipping addresses
326
+ - [Promotions](/developer/core-concepts/promotions) — Discounts and coupon codes
327
+ - [Checkout Customization](/developer/customization/checkout) — Customizing the checkout flow
328
+ - [Events](/developer/core-concepts/events) — Subscribe to order events (e.g., `order.completed`)