@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.
- package/README.md +54 -0
- package/dist/api-reference/platform/authentication.md +38 -0
- package/dist/api-reference/store-api/authentication.md +188 -0
- package/dist/api-reference/store-api/errors.md +277 -0
- package/dist/api-reference/store-api/idempotency.md +129 -0
- package/dist/api-reference/store-api/introduction.md +34 -0
- package/dist/api-reference/store-api/localization.md +279 -0
- package/dist/api-reference/store-api/metadata.md +160 -0
- package/dist/api-reference/store-api/monetary-amounts.md +65 -0
- package/dist/api-reference/store-api/querying.md +399 -0
- package/dist/api-reference/store-api/rate-limitting.md +103 -0
- package/dist/api-reference/store-api/relations.md +185 -0
- package/dist/api-reference/storefront/authentication.md +88 -0
- package/dist/api-reference/tutorials/adyen-integration-guide-for-android.md +165 -0
- package/dist/api-reference/tutorials/adyen-integration-guide-for-ios.md +194 -0
- package/dist/api-reference/tutorials/quick-checkout-with-stripe.md +248 -0
- package/dist/api-reference/v2/fetching-multiple-resources.md +26 -0
- package/dist/api-reference/v2/filtering-and-sorting.md +53 -0
- package/dist/api-reference/v2/introduction.md +22 -0
- package/dist/api-reference/v2/pagination.md +37 -0
- package/dist/api-reference/webhooks-events.md +883 -0
- package/dist/developer/admin/admin.md +205 -0
- package/dist/developer/admin/authentication.md +59 -0
- package/dist/developer/admin/components.md +711 -0
- package/dist/developer/admin/custom-css.md +243 -0
- package/dist/developer/admin/custom-javascript.md +116 -0
- package/dist/developer/admin/extending-ui.md +1964 -0
- package/dist/developer/admin/form-builder.md +444 -0
- package/dist/developer/admin/helper-methods.md +531 -0
- package/dist/developer/admin/navigation.md +805 -0
- package/dist/developer/admin/tables.md +491 -0
- package/dist/developer/advanced/adding_spree_to_rails_app.md +106 -0
- package/dist/developer/cli/quickstart.md +137 -0
- package/dist/developer/contributing/creating-an-extension.md +258 -0
- package/dist/developer/contributing/developing-spree.md +339 -0
- package/dist/developer/contributing/quickstart.md +32 -0
- package/dist/developer/contributing/updating-extensions.md +67 -0
- package/dist/developer/core-concepts/addresses.md +265 -0
- package/dist/developer/core-concepts/adjustments.md +107 -0
- package/dist/developer/core-concepts/architecture.md +177 -0
- package/dist/developer/core-concepts/calculators.md +323 -0
- package/dist/developer/core-concepts/customers.md +230 -0
- package/dist/developer/core-concepts/events.md +624 -0
- package/dist/developer/core-concepts/imports-exports.md +698 -0
- package/dist/developer/core-concepts/inventory.md +191 -0
- package/dist/developer/core-concepts/markets.md +250 -0
- package/dist/developer/core-concepts/media.md +167 -0
- package/dist/developer/core-concepts/metafields.md +187 -0
- package/dist/developer/core-concepts/orders.md +328 -0
- package/dist/developer/core-concepts/payments.md +710 -0
- package/dist/developer/core-concepts/pricing.md +163 -0
- package/dist/developer/core-concepts/products.md +360 -0
- package/dist/developer/core-concepts/promotions.md +322 -0
- package/dist/developer/core-concepts/reports.md +206 -0
- package/dist/developer/core-concepts/search-filtering.md +237 -0
- package/dist/developer/core-concepts/shipments.md +212 -0
- package/dist/developer/core-concepts/slugs.md +111 -0
- package/dist/developer/core-concepts/staff-roles.md +123 -0
- package/dist/developer/core-concepts/store-credits-gift-cards.md +317 -0
- package/dist/developer/core-concepts/stores.md +117 -0
- package/dist/developer/core-concepts/taxes.md +135 -0
- package/dist/developer/core-concepts/translations.md +120 -0
- package/dist/developer/core-concepts/users.md +299 -0
- package/dist/developer/core-concepts/webhooks.md +378 -0
- package/dist/developer/create-spree-app/quickstart.md +158 -0
- package/dist/developer/customization/api.md +93 -0
- package/dist/developer/customization/authentication.md +88 -0
- package/dist/developer/customization/checkout.md +204 -0
- package/dist/developer/customization/configuration.md +55 -0
- package/dist/developer/customization/decorators.md +523 -0
- package/dist/developer/customization/dependencies.md +232 -0
- package/dist/developer/customization/emails.md +21 -0
- package/dist/developer/customization/extensions.md +92 -0
- package/dist/developer/customization/metadata.md +236 -0
- package/dist/developer/customization/model-preferences.md +130 -0
- package/dist/developer/customization/permissions.md +265 -0
- package/dist/developer/customization/quickstart.md +229 -0
- package/dist/developer/customization/routes.md +24 -0
- package/dist/developer/customization/v4/admin-panel.md +78 -0
- package/dist/developer/customization/v4/authentication.md +210 -0
- package/dist/developer/customization/v4/checkout.md +212 -0
- package/dist/developer/customization/v4/deface.md +251 -0
- package/dist/developer/customization/v4/images.md +86 -0
- package/dist/developer/customization/v4/storefront.md +450 -0
- package/dist/developer/deployment/assets.md +87 -0
- package/dist/developer/deployment/aws.md +335 -0
- package/dist/developer/deployment/caching.md +27 -0
- package/dist/developer/deployment/cdn.md +39 -0
- package/dist/developer/deployment/database.md +155 -0
- package/dist/developer/deployment/docker.md +128 -0
- package/dist/developer/deployment/emails.md +77 -0
- package/dist/developer/deployment/environment_variables.md +111 -0
- package/dist/developer/deployment/heroku.md +51 -0
- package/dist/developer/deployment/render.md +95 -0
- package/dist/developer/getting-started/quickstart.md +82 -0
- package/dist/developer/how-to/custom-payment-method.md +374 -0
- package/dist/developer/how-to/custom-promotion.md +373 -0
- package/dist/developer/how-to/custom-report.md +387 -0
- package/dist/developer/how-to/custom-search-provider.md +230 -0
- package/dist/developer/multi-store/quickstart.md +71 -0
- package/dist/developer/multi-store/setup.md +38 -0
- package/dist/developer/multi-tenant/configuration.md +41 -0
- package/dist/developer/multi-tenant/core-concepts.md +75 -0
- package/dist/developer/multi-tenant/installation.md +96 -0
- package/dist/developer/multi-tenant/quickstart.md +20 -0
- package/dist/developer/multi-vendor/installation.md +45 -0
- package/dist/developer/multi-vendor/quickstart.md +17 -0
- package/dist/developer/sdk/admin/quickstart.md +22 -0
- package/dist/developer/sdk/authentication.md +89 -0
- package/dist/developer/sdk/configuration.md +225 -0
- package/dist/developer/sdk/quickstart.md +82 -0
- package/dist/developer/sdk/store/account.md +67 -0
- package/dist/developer/sdk/store/cart-checkout.md +140 -0
- package/dist/developer/sdk/store/markets.md +151 -0
- package/dist/developer/sdk/store/payments.md +96 -0
- package/dist/developer/sdk/store/products.md +149 -0
- package/dist/developer/sdk/store/wishlists.md +52 -0
- package/dist/developer/security/pci_compliance.md +15 -0
- package/dist/developer/security/security_policy.md +68 -0
- package/dist/developer/storefront/blocks.md +285 -0
- package/dist/developer/storefront/custom-css.md +260 -0
- package/dist/developer/storefront/custom-javascript.md +166 -0
- package/dist/developer/storefront/helper-methods.md +1288 -0
- package/dist/developer/storefront/links.md +298 -0
- package/dist/developer/storefront/nextjs/architecture.md +150 -0
- package/dist/developer/storefront/nextjs/customization.md +141 -0
- package/dist/developer/storefront/nextjs/deployment.md +180 -0
- package/dist/developer/storefront/nextjs/quickstart.md +92 -0
- package/dist/developer/storefront/nextjs/spree-next-package.md +314 -0
- package/dist/developer/storefront/pages.md +163 -0
- package/dist/developer/storefront/sections.md +569 -0
- package/dist/developer/storefront/storefront.md +56 -0
- package/dist/developer/storefront/themes.md +161 -0
- package/dist/developer/tutorial/admin.md +134 -0
- package/dist/developer/tutorial/extending-models.md +380 -0
- package/dist/developer/tutorial/file-uploads.md +121 -0
- package/dist/developer/tutorial/introduction.md +33 -0
- package/dist/developer/tutorial/model.md +41 -0
- package/dist/developer/tutorial/page-builder.md +487 -0
- package/dist/developer/tutorial/rich-text.md +73 -0
- package/dist/developer/tutorial/seo.md +332 -0
- package/dist/developer/tutorial/storefront.md +352 -0
- package/dist/developer/tutorial/testing.md +558 -0
- package/dist/developer/upgrades/2.0-to-2.1.md +46 -0
- package/dist/developer/upgrades/2.1-to-2.2.md +59 -0
- package/dist/developer/upgrades/2.2-to-2.3.md +44 -0
- package/dist/developer/upgrades/2.3-to-2.4.md +42 -0
- package/dist/developer/upgrades/3.0-to-3.1.md +47 -0
- package/dist/developer/upgrades/3.1-to-3.2.md +34 -0
- package/dist/developer/upgrades/3.2-to-3.3.md +70 -0
- package/dist/developer/upgrades/3.3-to-3.4.md +36 -0
- package/dist/developer/upgrades/3.4-to-3.5.md +44 -0
- package/dist/developer/upgrades/3.5-to-3.6.md +40 -0
- package/dist/developer/upgrades/3.6-to-3.7.md +62 -0
- package/dist/developer/upgrades/3.7-to-4.0.md +152 -0
- package/dist/developer/upgrades/4.0-to-4.1.md +92 -0
- package/dist/developer/upgrades/4.1-to-4.2.md +109 -0
- package/dist/developer/upgrades/4.10-to-5.0.md +129 -0
- package/dist/developer/upgrades/4.2-to-4.3.md +100 -0
- package/dist/developer/upgrades/4.3-to-4.4.md +125 -0
- package/dist/developer/upgrades/4.4-to-4.5.md +94 -0
- package/dist/developer/upgrades/4.5-to-4.6.md +119 -0
- package/dist/developer/upgrades/4.6-to-4.7.md +39 -0
- package/dist/developer/upgrades/4.8-to-4.9.md +24 -0
- package/dist/developer/upgrades/4.9-to-4.10.md +24 -0
- package/dist/developer/upgrades/4.x-to-4.8.md +52 -0
- package/dist/developer/upgrades/5.0-to-5.1.md +28 -0
- package/dist/developer/upgrades/5.1-to-5.2.md +127 -0
- package/dist/developer/upgrades/5.2-to-5.3.md +338 -0
- package/dist/developer/upgrades/5.3-to-5.4.md +248 -0
- package/dist/developer/upgrades/quickstart.md +36 -0
- package/dist/integrations/analytics/google-analytics.md +64 -0
- package/dist/integrations/analytics/google-tag-manager.md +78 -0
- package/dist/integrations/integrations.md +39 -0
- package/dist/integrations/marketing/klaviyo.md +99 -0
- package/dist/integrations/payments/adyen.md +90 -0
- package/dist/integrations/payments/paypal.md +41 -0
- package/dist/integrations/payments/razorpay.md +45 -0
- package/dist/integrations/payments/stripe.md +109 -0
- package/dist/integrations/search/meilisearch.md +236 -0
- package/dist/integrations/sso-mfa-social-login/admin-dashboard.md +57 -0
- package/dist/integrations/sso-mfa-social-login/storefront.md +56 -0
- package/package.json +27 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "create-spree-app"
|
|
3
|
+
sidebarTitle: Overview
|
|
4
|
+
description: "Scaffold a new Spree Commerce project with a single command. Includes a full Rails backend app for customization."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx create-spree-app@latest my-store
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The CLI walks you through an interactive setup:
|
|
14
|
+
|
|
15
|
+
1. Include **Next.js Storefront** (default: yes)
|
|
16
|
+
2. Optionally load **sample data** (products, categories, images)
|
|
17
|
+
3. Optionally **start Docker services** immediately
|
|
18
|
+
|
|
19
|
+
Once complete, your store is running at [http://localhost:3000](http://localhost:3000).
|
|
20
|
+
|
|
21
|
+
## Prerequisites
|
|
22
|
+
|
|
23
|
+
- [Node.js](https://nodejs.org/) 20 or later
|
|
24
|
+
- [Docker](https://docs.docker.com/get-docker/) (for running the Spree backend, PostgreSQL, and Redis)
|
|
25
|
+
|
|
26
|
+
## CLI Flags
|
|
27
|
+
|
|
28
|
+
All prompts can be skipped with flags for non-interactive (CI/CD) usage:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx create-spree-app@latest my-store --no-storefront --no-sample-data --no-start
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
| Flag | Description |
|
|
35
|
+
|------|-------------|
|
|
36
|
+
| `--no-storefront` | Skip Next.js storefront setup |
|
|
37
|
+
| `--no-sample-data` | Skip loading sample products and categories |
|
|
38
|
+
| `--no-start` | Don't start Docker services after scaffolding |
|
|
39
|
+
| `--port <number>` | Port for the Spree backend (default: `3000`) |
|
|
40
|
+
| `--use-npm` | Use npm as package manager |
|
|
41
|
+
| `--use-yarn` | Use yarn as package manager |
|
|
42
|
+
| `--use-pnpm` | Use pnpm as package manager |
|
|
43
|
+
|
|
44
|
+
> **TIP:** The package manager is auto-detected from how you run the command. If you use `pnpm dlx create-spree-app`, pnpm will be used automatically.
|
|
45
|
+
|
|
46
|
+
> **TIP:** If the default port is already in use, the CLI will automatically find a free port and let you know.
|
|
47
|
+
|
|
48
|
+
## Generated Project Structure
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
my-store/
|
|
52
|
+
├── docker-compose.yml # Spree backend (prebuilt image) + Postgres + Redis
|
|
53
|
+
├── docker-compose.dev.yml # Alternative: build from local backend/
|
|
54
|
+
├── .env # SECRET_KEY_BASE, SPREE_PORT
|
|
55
|
+
├── .gitignore
|
|
56
|
+
├── package.json # Convenience scripts
|
|
57
|
+
├── README.md
|
|
58
|
+
├── backend/ # Full Rails app (from spree/spree-starter)
|
|
59
|
+
│ ├── Gemfile
|
|
60
|
+
│ ├── Dockerfile
|
|
61
|
+
│ ├── config/
|
|
62
|
+
│ ├── app/
|
|
63
|
+
│ └── ...
|
|
64
|
+
└── apps/
|
|
65
|
+
└── storefront/ # Next.js storefront (unless --no-storefront)
|
|
66
|
+
├── .env.local # API URL + API key
|
|
67
|
+
└── ...
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### What's in docker-compose.yml
|
|
71
|
+
|
|
72
|
+
- **Spree** — runs the `ghcr.io/spree/spree:latest` image on the configured port (default `3000`)
|
|
73
|
+
- **PostgreSQL 18** — database with persistent volume
|
|
74
|
+
- **Redis 7** — caching, background jobs, and Action Cable
|
|
75
|
+
- **Mailpit** — local email inbox at [http://localhost:8025](http://localhost:8025)
|
|
76
|
+
- Health checks on all services
|
|
77
|
+
|
|
78
|
+
## Customizing the Backend
|
|
79
|
+
|
|
80
|
+
The `backend/` directory contains a full Rails application with Spree installed (cloned from [spree-starter](https://github.com/spree/spree-starter)). By default, the project uses a prebuilt Docker image. To switch to building from your local backend:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npx spree eject
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This replaces `docker-compose.yml` with a version that builds from `backend/`, rebuilds the image, and restarts services. You can then:
|
|
87
|
+
|
|
88
|
+
- **Add gems** to `backend/Gemfile`
|
|
89
|
+
- **Override models** with decorators in `backend/app/models/`
|
|
90
|
+
- **Add controllers** in `backend/app/controllers/`
|
|
91
|
+
- **Configure Spree** in `backend/config/initializers/spree.rb`
|
|
92
|
+
- **Add migrations** with `cd backend && bin/rails generate migration`
|
|
93
|
+
|
|
94
|
+
See the [Customization Guide](/developer/customization) for more details.
|
|
95
|
+
|
|
96
|
+
### Spree CLI Commands
|
|
97
|
+
|
|
98
|
+
The project includes [@spree/cli](/developer/cli/quickstart) for managing your Spree backend:
|
|
99
|
+
|
|
100
|
+
| Command | Description |
|
|
101
|
+
|---------|-------------|
|
|
102
|
+
| `spree dev` | Start backend services and stream logs |
|
|
103
|
+
| `spree stop` | Stop backend services |
|
|
104
|
+
| `spree update` | Pull latest Spree image and restart (runs migrations automatically) |
|
|
105
|
+
| `spree eject` | Switch from prebuilt image to building from `backend/` |
|
|
106
|
+
| `spree logs` | View backend logs |
|
|
107
|
+
| `spree logs worker` | View background jobs logs |
|
|
108
|
+
| `spree console` | Rails console |
|
|
109
|
+
|
|
110
|
+
## After Setup
|
|
111
|
+
|
|
112
|
+
### Admin Dashboard
|
|
113
|
+
|
|
114
|
+
Open [http://localhost:3000/admin](http://localhost:3000/admin) and log in with:
|
|
115
|
+
|
|
116
|
+
| | |
|
|
117
|
+
|---|---|
|
|
118
|
+
| **Email** | `spree@example.com` |
|
|
119
|
+
| **Password** | `spree123` |
|
|
120
|
+
|
|
121
|
+
### Store API
|
|
122
|
+
|
|
123
|
+
The REST API is available at [http://localhost:3000/api/v3/store](http://localhost:3000/api/v3/store). See the [API Reference](/api-reference) for details.
|
|
124
|
+
|
|
125
|
+
### Storefront
|
|
126
|
+
|
|
127
|
+
If you included the storefront, start it in a separate terminal:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
cd my-store/apps/storefront
|
|
131
|
+
npm run dev
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Open [http://localhost:3001](http://localhost:3001) to see your store.
|
|
135
|
+
|
|
136
|
+
## Updating Spree
|
|
137
|
+
|
|
138
|
+
To update to the latest Spree version:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
spree update
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
This pulls the latest Docker image and recreates the containers. The entrypoint automatically runs database migrations.
|
|
145
|
+
|
|
146
|
+
To pin a specific version, edit `SPREE_VERSION_TAG` in `.env`:
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
SPREE_VERSION_TAG=5.4
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Next Steps
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
- [Next.js Storefront](/developer/storefront/nextjs/quickstart) — Customize and extend the Storefront
|
|
156
|
+
- [Spree SDK](/developer/sdk/quickstart) — TypeScript SDK for the Store and Admin APIs
|
|
157
|
+
- [API Reference](/api-reference) — Explore the REST API endpoints
|
|
158
|
+
- [Core Concepts](/developer/core-concepts/architecture) — Learn about Spree's architecture
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: API
|
|
3
|
+
description: >-
|
|
4
|
+
This page covers adding new Spree API endpoints and customization of
|
|
5
|
+
existing ones
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Before you start customizing Spree API endpoints, make sure you reviewed all existing API endpoints in the [Spree API docs](/api-reference).
|
|
9
|
+
|
|
10
|
+
## Customizing JSON response
|
|
11
|
+
|
|
12
|
+
Spree uses a library called [JSON API serializers](https://github.com/jsonapi-serializer/jsonapi-serializer) to represent data returned by API endpoints.
|
|
13
|
+
|
|
14
|
+
You can easily replace existing Spree serializers with your own thanks to [Spree Dependencies](dependencies). Here's a list of all serializers that you can override:
|
|
15
|
+
|
|
16
|
+
| Key | Value |
|
|
17
|
+
|------------------------------------------|-----------------------------------------------------|
|
|
18
|
+
| `storefront_address_serializer` | [Spree::V2::Storefront::AddressSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/address_serializer.rb) |
|
|
19
|
+
| `storefront_cart_serializer` | [Spree::V2::Storefront::CartSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/cart_serializer.rb) |
|
|
20
|
+
| `storefront_credit_card_serializer` | [Spree::V2::Storefront::CreditCardSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/credit_card_serializer.rb) |
|
|
21
|
+
| `storefront_country_serializer` | [Spree::V2::Storefront::CountrySerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/country_serializer.rb) |
|
|
22
|
+
| `storefront_user_serializer` | [Spree::V2::Storefront::UserSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/user_serializer.rb) |
|
|
23
|
+
| `storefront_shipment_serializer` | [Spree::V2::Storefront::ShipmentSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/shipment_serializer.rb) |
|
|
24
|
+
| `storefront_taxon_serializer` | [Spree::V2::Storefront::TaxonSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/taxon_serializer.rb) |
|
|
25
|
+
| `storefront_payment_method_serializer` | [Spree::V2::Storefront::PaymentMethodSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/payment_method_serializer.rb) |
|
|
26
|
+
| `storefront_payment_serializer` | [Spree::V2::Storefront::PaymentSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/payment_serializer.rb) |
|
|
27
|
+
| `storefront_product_serializer` | [Spree::V2::Storefront::ProductSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/product_serializer.rb) |
|
|
28
|
+
| `storefront_estimated_shipment_serializer` | [Spree::V2::Storefront::EstimatedShippingRateSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/estimated_shipping_rate_serializer.rb) |
|
|
29
|
+
| `storefront_store_serializer` | [Spree::V2::Storefront::StoreSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/store_serializer.rb) |
|
|
30
|
+
| `storefront_order_serializer` | [Spree::V2::Storefront::OrderSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/order_serializer.rb) |
|
|
31
|
+
| `storefront_variant_serializer` | [Spree::V2::Storefront::VariantSerializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/variant_serializer.rb) |
|
|
32
|
+
|
|
33
|
+
### Adding custom attributes
|
|
34
|
+
|
|
35
|
+
> **NOTE:** As a rule of thumb it's recommended to use [Properties](/developer/core-concepts/products#product-properties) and [OptionTypes/Option Values](/developer/core-concepts/products#option-types-and-option-values) for custom attributes and not to modify the Spree database schema
|
|
36
|
+
|
|
37
|
+
Let's say you want to customize the Storefront API's [Product serializer](https://github.com/spree/spree/blob/main/api/app/serializers/spree/v2/storefront/product_serializer.rb) to include you custom database column `my_newcustom_attribute` that you've added to the `spree_products` database table.
|
|
38
|
+
|
|
39
|
+
Let's start with creating a new serializer file:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
mkdir -p app/serializers && touch app/serializers/my_product_serializer.rb
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Place the following code in your new serializer file:
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
class MyProductSerializer < Spree::V2::Storefront::ProductSerializer
|
|
49
|
+
attribute :my_new_custom_attribute
|
|
50
|
+
end
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> **INFO:** This serializer will inherit from the `Spree::V2::Storefront::ProductSerializer` serializer, so you don't need to rewrite the whole serializer.
|
|
54
|
+
|
|
55
|
+
Now let's tell Spree to use this new serializer, in `config/initializers/spree.rb` please set:
|
|
56
|
+
|
|
57
|
+
```ruby
|
|
58
|
+
Spree::Api::Dependencies.storefront_product_serializer = 'MyProductSerializer'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Restart the webserver and hit the [Products API](/api-reference/storefront/products/list-all-products) to notice that the payload now includes your new attribute.
|
|
62
|
+
|
|
63
|
+
### Adding a new association
|
|
64
|
+
|
|
65
|
+
Let's say you've created a new model called `Video` that belongs to `Product` (_Product has multiple Videos_).
|
|
66
|
+
|
|
67
|
+
Let's create a new serializer `app/serializers/video_serializer.rb`:
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
class VideoSerializer < Spree::Api::V2::BaseSerializer
|
|
71
|
+
set_type: :video
|
|
72
|
+
|
|
73
|
+
attributes :url
|
|
74
|
+
end
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Now in your `app/serializers/my_product_serializer.rb`
|
|
78
|
+
|
|
79
|
+
```ruby
|
|
80
|
+
class MyProductSerializer < Spree::V2::Storefront::ProductSerializer
|
|
81
|
+
attribute :my_new_custom_attribute
|
|
82
|
+
|
|
83
|
+
has_many :videos, serializer: :video
|
|
84
|
+
end
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Hitting the Products API you will notice that in the [relationships](https://jsonapi.org/format/#document-resource-object-relationships) key there will be a new key called `videos`
|
|
88
|
+
|
|
89
|
+
To include Video response in the Product API add `?includes=videos` in the API URL, eg.
|
|
90
|
+
|
|
91
|
+
```http
|
|
92
|
+
GET https://localhost:3000/api/v2/storefront/products?include=videos
|
|
93
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Authentication
|
|
3
|
+
description: Learn how to use a custom authentication setup with Spree
|
|
4
|
+
version: v5
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
If you installed Spree following the [Quickstart guide](/developer/quickstart), you can completely skip this step - you are all set and integrated with the [Devise](https://github.com/plataformatec/devise) gem.
|
|
8
|
+
|
|
9
|
+
However if you're adding Spree to an existing application that has its own authentication system, you will need to follow these steps.
|
|
10
|
+
|
|
11
|
+
## Using Devise
|
|
12
|
+
|
|
13
|
+
If you're currently using [Devise](https://github.com/plataformatec/devise) for authentication, you can follow the steps below to integrate Spree with your existing authentication system.
|
|
14
|
+
|
|
15
|
+
Firstly set your `User` class as `Spree.user_class` in your `config/initializers/spree.rb` file:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
Spree.user_class = 'User'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now, run the generator to setup Spree integration with Devise:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bin/rails g spree:authentication:devise
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
This will create the a new file in `lib/spree/authentication_helpers.rb` that serves as a bridge between Spree and your existing authentication system routes. You can then use this file to customize the routes to your liking. It should automatically pick up standard Devise routes.
|
|
28
|
+
|
|
29
|
+
Secondly, this generator will add necessary modules to your `User` model.
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
# app/models/user.rb
|
|
33
|
+
class User < ApplicationRecord
|
|
34
|
+
# ... your existing code ...
|
|
35
|
+
|
|
36
|
+
include Spree::UserAddress
|
|
37
|
+
include Spree::UserMethods
|
|
38
|
+
include Spree::UserPaymentSource
|
|
39
|
+
end
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This will ensure that your `User` model can be used as a Spree user.
|
|
43
|
+
|
|
44
|
+
This generator will also add 2 new lines to your Spree initializer file:
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
Devise.parent_controller = "Spree::BaseController"
|
|
48
|
+
Devise.parent_mailer = "Spree::BaseMailer"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This ensures that Devise will use Spree storefront layout for login/signup/etc and use Spree mailer layout for sending emails so they'll match your Storefront branding.
|
|
52
|
+
|
|
53
|
+
If you have more complex setup, you can remove these lines and customize the routes and mailer in your own initializer file.
|
|
54
|
+
|
|
55
|
+
## Using Custom Authentication
|
|
56
|
+
|
|
57
|
+
If you're using a custom authentication system, you can follow the steps below to integrate Spree with your existing authentication system.
|
|
58
|
+
|
|
59
|
+
Firstly set your `User` class as `Spree.user_class` in your `config/initializers/spree.rb` file:
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
Spree.user_class = 'User'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Now, run the generator to setup Spree integration with your custom authentication system:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
bin/rails g spree:authentication:custom
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This will create the a new file in `lib/spree/authentication_helpers.rb` that serves as a bridge between Spree and your existing authentication system routes. You will need to customize this file to fit your needs.
|
|
72
|
+
|
|
73
|
+
Secondly, this generator will add necessary modules to your `User` model.
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
# app/models/user.rb
|
|
77
|
+
class User < ApplicationRecord
|
|
78
|
+
# ... your existing code ...
|
|
79
|
+
|
|
80
|
+
include Spree::UserAddress
|
|
81
|
+
include Spree::UserMethods
|
|
82
|
+
include Spree::UserPaymentSource
|
|
83
|
+
end
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Admin Panel authentication
|
|
87
|
+
|
|
88
|
+
Please refer to the [Admin Panel Authentication](/developer/admin/authentication) page for more details.
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Checkout Flow
|
|
3
|
+
description: Learn how to customize the checkout process in Spree.
|
|
4
|
+
version: v5
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
The Spree checkout process has been designed for maximum flexibility. It's been redesigned several times now, each iteration has benefited from the feedback of real-world deployment experience. It is relatively simple to customize the checkout process to suit your needs. Secure transmission of customer information is possible via SSL and credit card information is never stored in the database.
|
|
10
|
+
|
|
11
|
+
## The Checkout Flow DSL
|
|
12
|
+
|
|
13
|
+
Spree comes with a new checkout DSL that allows you succinctly define the different steps of your checkout. This new DSL allows you to customize _just_ the checkout flow, while maintaining the unrelated admin states, such as "canceled" and "resumed", that an order can transition to. Ultimately, it provides a shorter syntax compared with overriding the entire state machine for the `Spree::Order` class.
|
|
14
|
+
|
|
15
|
+
The default checkout flow for Spree is defined like this, adequately demonstrating the abilities of this new system:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
checkout_flow do
|
|
19
|
+
go_to_state :address
|
|
20
|
+
go_to_state :delivery
|
|
21
|
+
go_to_state :payment, if: ->(order) {
|
|
22
|
+
order.update_totals
|
|
23
|
+
order.payment_required?
|
|
24
|
+
}
|
|
25
|
+
go_to_state :confirm, if: ->(order) { order.confirmation_required? }
|
|
26
|
+
go_to_state :complete
|
|
27
|
+
remove_transition from: :delivery, to: :confirm
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
we can pass a block on each checkout step definition and work some logic to figure if the step is required dynamically. e.g. the confirm step might only be necessary for payment gateways that support payment profiles.
|
|
31
|
+
|
|
32
|
+
These conditional states present a situation where an order could transition from delivery to one of payment, confirm or complete. In the default checkout, we never want to transition from delivery to confirm, and therefore have removed it using the `remove_transition` method of the Checkout DSL. The resulting transitions between states look like the image below:
|
|
33
|
+
|
|
34
|
+
These two helper methods are provided on `Spree::Order` instances for your convenience:
|
|
35
|
+
|
|
36
|
+
* `checkout_steps` - returns a list of all the potential states of the checkout.
|
|
37
|
+
* `has_step?` - Used to check if the current order fulfills the requirements for a specific state.
|
|
38
|
+
|
|
39
|
+
If you want a list of all the currently available states for the checkout, use the `checkout_steps` method, which will return the steps in an array.
|
|
40
|
+
|
|
41
|
+
## Default Checkout Steps
|
|
42
|
+
|
|
43
|
+
The Spree checkout process consists of the following steps. With the exception of the Registration step, each of these steps corresponds to a state of the [Order object](/developer/core-concepts/orders):
|
|
44
|
+
|
|
45
|
+
* Shipping Address and Contact Information
|
|
46
|
+
* Delivery Options Shipping Method
|
|
47
|
+
* Payment and Billing Information
|
|
48
|
+
* Confirmation (optional)
|
|
49
|
+
|
|
50
|
+
The following sections will provide a walk-through of checkout from a user's perspective, and offer some information on how to configure the default behavior of the various steps.
|
|
51
|
+
|
|
52
|
+
### Shipping Address and Contact Information
|
|
53
|
+
|
|
54
|
+
This step allows the customer to add shipping information and contact information. Customers have also option to sign in or create an account. For payment methods such as Stripe customers can use quick checkout option via payment wallets such as Apple Pay, Google Pay, etc and skip the rest of the checkout process.
|
|
55
|
+
|
|
56
|
+
The address fields include a select box for choosing state/province. If there are no states configured for a particular country, the select box will be replaced by a text field instead.
|
|
57
|
+
|
|
58
|
+
The list of countries that appear in the country select box can also be configured. Spree will list all countries by default, but you can configure exactly which countries you would like to appear. The list can be limited to a specific set of countries by [setting the Store's checkout zone](/developer/core-concepts/stores#checkout-configuration).
|
|
59
|
+
|
|
60
|
+
### Delivery Options
|
|
61
|
+
|
|
62
|
+
During this step, the user may choose a delivery method. Spree assumes the list of shipping methods to be dependent on the shipping address. If there are multiple shipments eg. different Stock Locations or Vendors, the user will be asked to select shipping method for each shipment.
|
|
63
|
+
|
|
64
|
+
### Payment
|
|
65
|
+
|
|
66
|
+
This step is where the customer provides payment and billing information. Spree does not store any payment information in the database. For payment methods such as Stripe, we use Stripe JavaScript SDKs to render their payment form inside the checkout page, fully compliant with PCI DSS standards.
|
|
67
|
+
|
|
68
|
+
Besides Credit Card, Wallets and other 3rd party payment methods, Spree also supports Store Credit and Gift Cards (Spree 5.1+ only) which can be used to pay for the entire order or part of the order.
|
|
69
|
+
|
|
70
|
+
For more information about payments, please see the [Payments guide](/developer/core-concepts/payments).
|
|
71
|
+
|
|
72
|
+
### Confirmation
|
|
73
|
+
|
|
74
|
+
This is the final opportunity for the customer to review their order before submitting it to be processed. Users have the opportunity to return to any step in the process using either the back button or by clicking on the appropriate step in the "progress breadcrumb."
|
|
75
|
+
|
|
76
|
+
This step is disabled by default, but can be enabled by two ways:
|
|
77
|
+
|
|
78
|
+
1. globally for all orders by setting a preference in `config/initializers/spree.rb`:
|
|
79
|
+
|
|
80
|
+
```ruby config/initializers/spree.rb
|
|
81
|
+
Spree::Config[:always_include_confirm_step] = true
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
2. conditionally for specific orders by overriding the `confirmation_required?` method in `Spree::Order` with a [decorator](/developer/customization/decorators), eg.
|
|
85
|
+
|
|
86
|
+
```ruby app/models/spree/order_decorator.rb
|
|
87
|
+
module Spree
|
|
88
|
+
module OrderDecorator
|
|
89
|
+
# require confirmation for orders with a US billing address
|
|
90
|
+
def confirmation_required?
|
|
91
|
+
billing_address&.country_iso == 'US'
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Adding Logic Before or After a Particular Step
|
|
98
|
+
|
|
99
|
+
There are two approaches for adding logic around checkout state transitions:
|
|
100
|
+
|
|
101
|
+
### Approach 1: Events Subscribers (Recommended for side effects)
|
|
102
|
+
|
|
103
|
+
For actions that should happen **after** a checkout step completes (syncing with external services, sending notifications, logging, etc.), use [Events subscribers](/developer/core-concepts/events). This is the recommended approach because it keeps your code decoupled from Spree internals.
|
|
104
|
+
|
|
105
|
+
```ruby app/subscribers/my_app/order_completed_subscriber.rb
|
|
106
|
+
module MyApp
|
|
107
|
+
class OrderCompletedSubscriber < Spree::Subscriber
|
|
108
|
+
subscribes_to 'order.completed'
|
|
109
|
+
|
|
110
|
+
def handle(event)
|
|
111
|
+
order = Spree::Order.find_by(id: event.payload['id'])
|
|
112
|
+
return unless order
|
|
113
|
+
|
|
114
|
+
# Sync to fulfillment system, notify warehouse, etc.
|
|
115
|
+
FulfillmentService.notify(order)
|
|
116
|
+
AnalyticsService.track_purchase(order)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
> **INFO:** Events are fired automatically when orders change state. See [Events documentation](/developer/core-concepts/events#order-events) for all available order events.
|
|
123
|
+
|
|
124
|
+
### Approach 2: State Machine Callbacks (For validation/blocking logic)
|
|
125
|
+
|
|
126
|
+
The [state_machines](https://github.com/state-machines/state_machines) gem allows you to implement callbacks that can **block** transitions. Use this approach only when you need to prevent a transition based on validation logic.
|
|
127
|
+
|
|
128
|
+
For example, if you wanted to verify that the user provides a valid zip code before transitioning to the delivery step:
|
|
129
|
+
|
|
130
|
+
```ruby app/models/spree/order_decorator.rb
|
|
131
|
+
module Spree
|
|
132
|
+
module OrderDecorator
|
|
133
|
+
def self.prepended(base)
|
|
134
|
+
base.state_machine.before_transition to: :delivery, do: :valid_zip_code?
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def valid_zip_code?
|
|
138
|
+
# Return false to prevent the transition
|
|
139
|
+
ship_address&.zipcode&.match?(/^\d{5}(-\d{4})?$/)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
Order.prepend(OrderDecorator)
|
|
144
|
+
end
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
This callback would prevent transitioning to the `delivery` step if `valid_zip_code?` returns false.
|
|
148
|
+
|
|
149
|
+
> **WARNING:** Avoid using state machine callbacks for side effects like API calls or notifications. These can slow down checkout and may fail silently. Use [Events subscribers](/developer/core-concepts/events) instead.
|
|
150
|
+
|
|
151
|
+
## Modifying the checkout flow
|
|
152
|
+
|
|
153
|
+
To add or remove steps to the checkout flow, you can use the
|
|
154
|
+
[insert_checkout_step](https://github.com/spree/spree/blob/a39ed2b69f1f2b2f413b7f46090bd0deeb439d61/core/app/models/spree/order/checkout.rb#L138) and [remove_checkout_step](https://github.com/spree/spree/blob/a39ed2b69f1f2b2f413b7f46090bd0deeb439d61/core/app/models/spree/order/checkout.rb#L157) helpers respectively.
|
|
155
|
+
|
|
156
|
+
The `insert_checkout_step` method takes a `before` or `after` option to determine where to insert the step:
|
|
157
|
+
|
|
158
|
+
```ruby app/models/spree/order_decorator.rb
|
|
159
|
+
module Spree
|
|
160
|
+
module OrderDecorator
|
|
161
|
+
def self.prepended(base)
|
|
162
|
+
base.insert_checkout_step :new_step, before: :address
|
|
163
|
+
# or
|
|
164
|
+
# base.insert_checkout_step :new_step, after: :address
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
Order.prepend(OrderDecorator)
|
|
169
|
+
end
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The `remove_checkout_step` will remove just one checkout step at a time:
|
|
173
|
+
|
|
174
|
+
```ruby app/models/spree/order_decorator.rb
|
|
175
|
+
module Spree
|
|
176
|
+
module OrderDecorator
|
|
177
|
+
def self.prepended(base)
|
|
178
|
+
base.remove_checkout_step :address
|
|
179
|
+
base.remove_checkout_step :delivery
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
Order.prepend(OrderDecorator)
|
|
184
|
+
end
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
What will happen here is that when a user goes to checkout, they will be asked to potentially fill in their payment details and then potentially confirm the order. This is the default behavior of the payment and the confirm steps within the checkout. If they are not required to provide payment or confirmation for this order then checking out this order will result in its immediate completion.
|
|
188
|
+
|
|
189
|
+
To completely re-define the flow of the checkout, use the `checkout_flow` helper:
|
|
190
|
+
|
|
191
|
+
```ruby app/models/spree/order_decorator.rb
|
|
192
|
+
module Spree
|
|
193
|
+
module OrderDecorator
|
|
194
|
+
def self.prepended(base)
|
|
195
|
+
base.checkout_flow do
|
|
196
|
+
go_to_state :payment
|
|
197
|
+
go_to_state :complete
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
Order.prepend(OrderDecorator)
|
|
203
|
+
end
|
|
204
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Configuration"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Here is a list of all the configuration options that are available in Spree.
|
|
6
|
+
|
|
7
|
+
| Configuration Key | Description | Default Value |
|
|
8
|
+
|------------------------------------|-------------------------------------------------------------------------------------------------------|---------------------|
|
|
9
|
+
| `allow_checkout_on_gateway_error` | Continues the checkout process even if the payment gateway error failed. | `false` |
|
|
10
|
+
| `address_requires_phone` | Determines whether a phone number is required for Addresses. | `false` |
|
|
11
|
+
| `alternative_shipping_phone` | Determines if an alternative phone number should be present for the shipping address on the checkout page. | `false` |
|
|
12
|
+
| `always_include_confirm_step` | Determines if the confirmation step is always included in the checkout process, regardless of the payment method. | `false` |
|
|
13
|
+
| `auto_capture` | Depending on whether or not Spree is configured to "auto capture" the credit card, either a purchase or an authorize operation will be performed on the card (via the current credit card gateway). | `true` |
|
|
14
|
+
| `auto_capture_on_dispatch` | Captures payment for each shipment in Shipment#after_ship callback, and makes Shipment.ready when payment authorized. | `false` |
|
|
15
|
+
| `company` | Determines whether or not a field for "Company" displays on the address form. | `false` |
|
|
16
|
+
| `credit_to_new_allocation` | Determines if a new allocation is created anytime store credit is added. If not set, it will update the store credit's amount in place. | `false` |
|
|
17
|
+
| `disable_sku_validation` | Determines if the built-in SKU uniqueness validation is disabled. | `false` |
|
|
18
|
+
| `disable_store_presence_validation` | Determines if Store presence validation for Products and Payment Methods is disabled. | `false` |
|
|
19
|
+
| `expedited_exchanges` | Determines if an exchange shipment is kicked off upon return authorization save. Requires payment profiles to be supported on your gateway and a configured delayed job handler. | `false` |
|
|
20
|
+
| `expedited_exchanges_days_window` | The number of days the customer has to return their item after the expedited exchange is shipped to avoid being charged. | `14` |
|
|
21
|
+
| `restock_inventory` | Determines if inventory should be restocked when an order is canceled or returned | `true` |
|
|
22
|
+
| `return_eligibility_number_of_days` | The number of days after purchase within which a return can be initiated. | `365` |
|
|
23
|
+
| `show_products_without_price` | Determines if products without a price are shown in the storefront and Storefront API | `false` |
|
|
24
|
+
| `tax_using_ship_address` | Determines if tax information should be based on shipping address, rather than the billing address. | `true` |
|
|
25
|
+
| `track_inventory_levels` | Determines if inventory levels should be tracked when products are purchased at checkout. This option causes new `InventoryUnit` objects to be created when a product is bought. | `true` |
|
|
26
|
+
|
|
27
|
+
## Spree Initializer
|
|
28
|
+
|
|
29
|
+
To change values for these preferences, you need to edit your `config/initializers/spree.rb` file.
|
|
30
|
+
|
|
31
|
+
For example, to disable the `expedited_exchanges` feature, you would add the following line:
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
Spree.config do |config|
|
|
35
|
+
config.expedited_exchanges = false
|
|
36
|
+
end
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> **NOTE:** Remember to restart your Rails server after making changes to the `config/initializers/spree.rb` file.
|
|
40
|
+
|
|
41
|
+
## Accessing Configuration
|
|
42
|
+
|
|
43
|
+
To access these preferences in your application, you can use the `Spree::Config` module. For example, to access the `expedited_exchanges` preference, you can do the following:
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
Spree::Config.expedited_exchanges
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This will return the current value of the `expedited_exchanges` preference. You can also set the value of a preference using the `Spree::Config` module. For example, to set the `expedited_exchanges` preference to `true`, you can do the following:
|
|
50
|
+
|
|
51
|
+
```ruby
|
|
52
|
+
Spree::Config.expedited_exchanges = true
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This will set the `expedited_exchanges` preference to `true` for the current process. After restarting the Rails server, the preference will return to the default value or the one set in the initializer.
|