@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,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Wishlists
|
|
3
|
+
description: Manage wishlists and wished items with the Spree SDK
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Wishlists
|
|
7
|
+
|
|
8
|
+
```typescript
|
|
9
|
+
const options = { token: jwtToken };
|
|
10
|
+
|
|
11
|
+
// List wishlists
|
|
12
|
+
const { data: wishlists } = await client.wishlists.list({}, options);
|
|
13
|
+
|
|
14
|
+
// Get wishlist by ID
|
|
15
|
+
const wishlist = await client.wishlists.get('wl_xxx', {
|
|
16
|
+
expand: ['wished_items'],
|
|
17
|
+
}, options);
|
|
18
|
+
|
|
19
|
+
// Create wishlist
|
|
20
|
+
const newWishlist = await client.wishlists.create({
|
|
21
|
+
name: 'Birthday Ideas',
|
|
22
|
+
is_private: true,
|
|
23
|
+
}, options);
|
|
24
|
+
|
|
25
|
+
// Update wishlist
|
|
26
|
+
await client.wishlists.update('wl_xxx', {
|
|
27
|
+
name: 'Updated Name',
|
|
28
|
+
}, options);
|
|
29
|
+
|
|
30
|
+
// Delete wishlist
|
|
31
|
+
await client.wishlists.delete('wl_xxx', options);
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Wishlist Items
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
const options = { token: jwtToken };
|
|
38
|
+
|
|
39
|
+
// Add item to wishlist
|
|
40
|
+
await client.wishlists.items.create('wl_xxx', {
|
|
41
|
+
variant_id: 'var_123',
|
|
42
|
+
quantity: 1,
|
|
43
|
+
}, options);
|
|
44
|
+
|
|
45
|
+
// Update item quantity
|
|
46
|
+
await client.wishlists.items.update('wl_xxx', 'wi_xxx', {
|
|
47
|
+
quantity: 2,
|
|
48
|
+
}, options);
|
|
49
|
+
|
|
50
|
+
// Remove item from wishlist
|
|
51
|
+
await client.wishlists.items.delete('wl_xxx', 'wi_xxx', options);
|
|
52
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "PCI Compliance"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
All store owners wishing to process credit card transactions should be familiar with [PCI Compliance](http://en.wikipedia.org/wiki/Pci_compliance). All officially supported payment gateways — [Spree Stripe](https://github.com/spree/spree_stripe), [Spree Adyen](https://github.com/spree/spree_adyen), and [Spree PayPal Checkout](https://github.com/spree/spree_paypal_checkout) — are fully PCI-compliant.
|
|
6
|
+
|
|
7
|
+
## Using payment tokens
|
|
8
|
+
|
|
9
|
+
We do not transmit or store Credit Card numbers. Instead we're using payment processor tokens supplied by their SDKs to authorize and charge customer cards. Sensitive payment data is collected directly by the gateway's frontend SDK (e.g., Stripe.js, Adyen Drop-in) and never touches your server.
|
|
10
|
+
|
|
11
|
+
## 3-D Secure and Strong Customer Authentication support
|
|
12
|
+
|
|
13
|
+
[Spree Stripe integration](https://github.com/spree/spree_stripe) supports [Strong Customer Authentication (SCA)](https://stripe.com/en-pl/guides/strong-customer-authentication) out of the box. We also use Stripe JavaScript SDK to render all payment forms.
|
|
14
|
+
|
|
15
|
+
[Spree Adyen integration](https://github.com/spree/spree_adyen) supports 3D Secure 2.0 through the Adyen Drop-in component.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Security Policy"
|
|
3
|
+
description: "How to report vulnerabilities, supported versions, and Spree's security practices."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
Proper application design, intelligent programming, and secure infrastructure are all essential in creating a secure e-commerce store using any software (Spree included). The Spree team has done its best to provide you with the tools to create a secure and profitable web presence, but it is up to you to take these tools and put them in good practice. We highly recommend reading and understanding the [Rails Security Guide](https://guides.rubyonrails.org/security.html).
|
|
9
|
+
|
|
10
|
+
## Supported Versions
|
|
11
|
+
|
|
12
|
+
The following versions are actively maintained and receive security patches.
|
|
13
|
+
|
|
14
|
+
| Version | Release date | End of life |
|
|
15
|
+
| ------- | ------------ | ----------- |
|
|
16
|
+
| 5.0 | 26.03.2025 | 26.03.2028 |
|
|
17
|
+
| 4.10 | 06.09.2024 | 06.09.2027 |
|
|
18
|
+
|
|
19
|
+
If you're using an older version [please upgrade](../upgrades/). Have trouble upgrading? [Contact us for support](https://spreecommerce.org/contact/).
|
|
20
|
+
|
|
21
|
+
**Versions that are not listed above will not receive any security patches or fixes.**
|
|
22
|
+
|
|
23
|
+
## Reporting Security Issues
|
|
24
|
+
|
|
25
|
+
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
|
|
26
|
+
|
|
27
|
+
Instead, please send an email to [security@spreecommerce.org](mailto:security@spreecommerce.org).
|
|
28
|
+
|
|
29
|
+
Please include as much of the following information as possible to help us triage your report:
|
|
30
|
+
|
|
31
|
+
- Type of vulnerability (e.g. SQL injection, XSS, CSRF, etc.)
|
|
32
|
+
- Affected version(s)
|
|
33
|
+
- Step-by-step instructions to reproduce the issue
|
|
34
|
+
- Proof of concept or exploit code (if available)
|
|
35
|
+
- Impact assessment of the vulnerability
|
|
36
|
+
|
|
37
|
+
### Submitting a Patch
|
|
38
|
+
|
|
39
|
+
If you would like to provide a patch yourself for the security issue **do not open a pull request for it**. Instead, create a commit on your fork of Spree and run this command:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git format-patch HEAD~1..HEAD --stdout > patch.txt
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Email a description of the patch along with the `patch.txt` file to [security@spreecommerce.org](mailto:security@spreecommerce.org).
|
|
46
|
+
|
|
47
|
+
### Disclosure Process
|
|
48
|
+
|
|
49
|
+
1. Security report is received and acknowledged within **48 hours**.
|
|
50
|
+
2. The issue is confirmed and a severity level is assigned.
|
|
51
|
+
3. A fix is developed and tested against all supported versions.
|
|
52
|
+
4. A new release is published with the fix and a [GitHub Security Advisory](https://github.com/spree/spree/security/advisories) is created.
|
|
53
|
+
5. Reporter is credited in the advisory (unless anonymity is requested).
|
|
54
|
+
|
|
55
|
+
### Security Advisories
|
|
56
|
+
|
|
57
|
+
Published security advisories can be found at [GitHub Security Advisories](https://github.com/spree/spree/security/advisories).
|
|
58
|
+
|
|
59
|
+
## Security Best Practices
|
|
60
|
+
|
|
61
|
+
Spree is built on **Ruby on Rails** which provides strong security defaults including protection against SQL injection, CSRF, and XSS. For more details on how Spree handles security in production environments, see the [Enterprise Security Overview](/user/security).
|
|
62
|
+
|
|
63
|
+
We recommend:
|
|
64
|
+
|
|
65
|
+
- Keeping Spree and all dependencies up to date
|
|
66
|
+
- Following the [Rails Security Guide](https://guides.rubyonrails.org/security.html)
|
|
67
|
+
- Using [bundler-audit](https://github.com/rubysec/bundler-audit) to scan for known vulnerabilities in dependencies
|
|
68
|
+
- Running [brakeman](https://github.com/presidentbeef/brakeman) for static security analysis
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Blocks"
|
|
3
|
+
description: "Learn how to utilize blocks to build your Spree Storefront"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Blocks are the lowest level of components in Spree Storefront. They are nested inside [sections](/developer/storefront/sections) and represent individual content elements like headings, text, buttons, and images.
|
|
7
|
+
|
|
8
|
+
## How Blocks Work
|
|
9
|
+
|
|
10
|
+
Each section can contain multiple blocks that store staff can manage through the Page Builder:
|
|
11
|
+
|
|
12
|
+
- Add new blocks
|
|
13
|
+
- Edit block content and settings
|
|
14
|
+
- Reorder blocks via drag-and-drop
|
|
15
|
+
- Remove blocks
|
|
16
|
+
|
|
17
|
+
Not all sections support blocks. A section must explicitly enable block support by implementing `blocks_available?` and `available_blocks_to_add` methods.
|
|
18
|
+
|
|
19
|
+
## Built-in Block Types
|
|
20
|
+
|
|
21
|
+
Spree comes with several built-in block types:
|
|
22
|
+
|
|
23
|
+
### Content Blocks
|
|
24
|
+
|
|
25
|
+
| Block | Description | Class |
|
|
26
|
+
|-------|-------------|-------|
|
|
27
|
+
| Heading | Large text headings | [Spree::PageBlocks::Heading](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/heading.rb) |
|
|
28
|
+
| Subheading | Smaller secondary headings | [Spree::PageBlocks::Subheading](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/subheading.rb) |
|
|
29
|
+
| Text | Rich text content | [Spree::PageBlocks::Text](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/text.rb) |
|
|
30
|
+
| Buttons | Call-to-action buttons with links | [Spree::PageBlocks::Buttons](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/buttons.rb) |
|
|
31
|
+
| Image | Image with optional link | [Spree::PageBlocks::Image](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/image.rb) |
|
|
32
|
+
|
|
33
|
+
### Navigation Blocks
|
|
34
|
+
|
|
35
|
+
| Block | Description | Class |
|
|
36
|
+
|-------|-------------|-------|
|
|
37
|
+
| Nav | Simple navigation links | [Spree::PageBlocks::Nav](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/nav.rb) |
|
|
38
|
+
| Mega Nav | Mega menu navigation | [Spree::PageBlocks::MegaNav](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/mega_nav.rb) |
|
|
39
|
+
| Link | Single link item | [Spree::PageBlocks::Link](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/link.rb) |
|
|
40
|
+
|
|
41
|
+
### Product Blocks
|
|
42
|
+
|
|
43
|
+
These blocks are used in the Product Details section:
|
|
44
|
+
|
|
45
|
+
| Block | Description | Class |
|
|
46
|
+
|-------|-------------|-------|
|
|
47
|
+
| Title | Product title | [Spree::PageBlocks::Products::Title](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/products/title.rb) |
|
|
48
|
+
| Price | Product price display | [Spree::PageBlocks::Products::Price](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/products/price.rb) |
|
|
49
|
+
| Description | Product description | [Spree::PageBlocks::Products::Description](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/products/description.rb) |
|
|
50
|
+
| Variant Picker | Size/color selector | [Spree::PageBlocks::Products::VariantPicker](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/products/variant_picker.rb) |
|
|
51
|
+
| Quantity Selector | Quantity input | [Spree::PageBlocks::Products::QuantitySelector](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/products/quantity_selector.rb) |
|
|
52
|
+
| Buy Buttons | Add to cart button | [Spree::PageBlocks::Products::BuyButtons](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/products/buy_buttons.rb) |
|
|
53
|
+
| Share | Social sharing buttons | [Spree::PageBlocks::Products::Share](https://github.com/spree/spree/blob/main/core/app/models/spree/page_blocks/products/share.rb) |
|
|
54
|
+
|
|
55
|
+
## Architecture
|
|
56
|
+
|
|
57
|
+
### Base Class
|
|
58
|
+
|
|
59
|
+
All blocks inherit from [Spree::PageBlock](https://github.com/spree/spree/blob/main/core/app/models/spree/page_block.rb):
|
|
60
|
+
|
|
61
|
+
```ruby
|
|
62
|
+
module Spree
|
|
63
|
+
class PageBlock < Spree.base_class
|
|
64
|
+
include Spree::HasPageLinks
|
|
65
|
+
|
|
66
|
+
belongs_to :section, class_name: 'Spree::PageSection'
|
|
67
|
+
|
|
68
|
+
has_rich_text :text
|
|
69
|
+
has_one_attached :asset
|
|
70
|
+
|
|
71
|
+
# Default preferences
|
|
72
|
+
preference :text_alignment, :string, default: 'left'
|
|
73
|
+
preference :container_alignment, :string, default: 'left'
|
|
74
|
+
preference :size, :string, default: 'medium'
|
|
75
|
+
preference :width_desktop, :integer, default: 100
|
|
76
|
+
preference :top_padding, :integer, default: 0
|
|
77
|
+
preference :bottom_padding, :integer, default: 0
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Default Preferences
|
|
83
|
+
|
|
84
|
+
Every block has these default preferences:
|
|
85
|
+
|
|
86
|
+
| Preference | Type | Default | Description |
|
|
87
|
+
|------------|------|---------|-------------|
|
|
88
|
+
| `text_alignment` | String | `left` | Text alignment (left, center, right) |
|
|
89
|
+
| `container_alignment` | String | `left` | Container alignment |
|
|
90
|
+
| `size` | String | `medium` | Block size (small, medium, large) |
|
|
91
|
+
| `width_desktop` | Integer | `100` | Width percentage on desktop |
|
|
92
|
+
| `top_padding` | Integer | `0` | Top padding in pixels |
|
|
93
|
+
| `bottom_padding` | Integer | `0` | Bottom padding in pixels |
|
|
94
|
+
|
|
95
|
+
### Associations
|
|
96
|
+
|
|
97
|
+
- **Section**: Each block belongs to a section (`section`)
|
|
98
|
+
- **Links**: Blocks can have multiple links (`links`) via `Spree::HasPageLinks`
|
|
99
|
+
- **Asset**: Blocks can have an attached image (`asset`)
|
|
100
|
+
- **Rich Text**: Blocks can have rich text content (`text`)
|
|
101
|
+
|
|
102
|
+
## Accessing Blocks
|
|
103
|
+
|
|
104
|
+
```ruby
|
|
105
|
+
# Get all blocks for a section
|
|
106
|
+
section.blocks
|
|
107
|
+
|
|
108
|
+
# Get blocks with eager loading
|
|
109
|
+
section.blocks.includes(:rich_text_text, :links)
|
|
110
|
+
|
|
111
|
+
# Find specific block type
|
|
112
|
+
section.blocks.where(type: 'Spree::PageBlocks::Heading')
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Rendering Blocks
|
|
116
|
+
|
|
117
|
+
In storefront section views, blocks are rendered within their parent section:
|
|
118
|
+
|
|
119
|
+
```erb
|
|
120
|
+
<% section.blocks.each do |block| %>
|
|
121
|
+
<% case block.type %>
|
|
122
|
+
<% when 'Spree::PageBlocks::Heading' %>
|
|
123
|
+
<h2 <%= block_attributes(block) %>>
|
|
124
|
+
<%= block.text %>
|
|
125
|
+
</h2>
|
|
126
|
+
<% when 'Spree::PageBlocks::Text' %>
|
|
127
|
+
<div <%= block_attributes(block) %>>
|
|
128
|
+
<%= block.text %>
|
|
129
|
+
</div>
|
|
130
|
+
<% when 'Spree::PageBlocks::Buttons' %>
|
|
131
|
+
<div <%= block_attributes(block) %>>
|
|
132
|
+
<% if block.link %>
|
|
133
|
+
<%= page_builder_link_to block.link, class: 'btn-primary' %>
|
|
134
|
+
<% end %>
|
|
135
|
+
</div>
|
|
136
|
+
<% end %>
|
|
137
|
+
<% end %>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
The `block_attributes(block)` helper returns data attributes needed for Page Builder editing.
|
|
141
|
+
|
|
142
|
+
## Creating a Custom Block
|
|
143
|
+
|
|
144
|
+
### Step 1: Create the Model
|
|
145
|
+
|
|
146
|
+
```ruby app/models/spree/page_blocks/quote.rb
|
|
147
|
+
module Spree
|
|
148
|
+
module PageBlocks
|
|
149
|
+
class Quote < Spree::PageBlock
|
|
150
|
+
SIZE_DEFAULT = 'large'
|
|
151
|
+
TEXT_ALIGNMENT_DEFAULT = 'center'
|
|
152
|
+
|
|
153
|
+
preference :author_name, :string
|
|
154
|
+
preference :author_title, :string
|
|
155
|
+
preference :text_color, :string
|
|
156
|
+
preference :background_color, :string
|
|
157
|
+
|
|
158
|
+
def icon_name
|
|
159
|
+
'quote'
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def display_name
|
|
163
|
+
text.to_plain_text.truncate(30)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Step 2: Register the Block
|
|
171
|
+
|
|
172
|
+
```ruby config/initializers/spree.rb
|
|
173
|
+
Rails.application.config.after_initialize do
|
|
174
|
+
Spree.page_builder.page_blocks += [
|
|
175
|
+
Spree::PageBlocks::Quote
|
|
176
|
+
]
|
|
177
|
+
end
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Step 3: Add to Section's Available Blocks
|
|
181
|
+
|
|
182
|
+
In your section model, add the new block type:
|
|
183
|
+
|
|
184
|
+
```ruby
|
|
185
|
+
def available_blocks_to_add
|
|
186
|
+
[
|
|
187
|
+
Spree::PageBlocks::Heading,
|
|
188
|
+
Spree::PageBlocks::Text,
|
|
189
|
+
Spree::PageBlocks::Quote # Your new block
|
|
190
|
+
]
|
|
191
|
+
end
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Step 4: Create Admin Form
|
|
195
|
+
|
|
196
|
+
```erb app/views/spree/admin/page_blocks/forms/_quote.html.erb
|
|
197
|
+
<div class="form-group">
|
|
198
|
+
<%= f.label :text, Spree.t(:quote_text) %>
|
|
199
|
+
<%= f.rich_text_area :text, data: { action: 'auto-submit#submit' } %>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<div class="form-group">
|
|
203
|
+
<%= f.label :preferred_author_name, Spree.t(:author_name) %>
|
|
204
|
+
<%= f.text_field :preferred_author_name,
|
|
205
|
+
class: 'form-control',
|
|
206
|
+
data: { action: 'auto-submit#submit' } %>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<div class="form-group">
|
|
210
|
+
<%= f.label :preferred_author_title, Spree.t(:author_title) %>
|
|
211
|
+
<%= f.text_field :preferred_author_title,
|
|
212
|
+
class: 'form-control',
|
|
213
|
+
data: { action: 'auto-submit#submit' } %>
|
|
214
|
+
</div>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Step 5: Render in Section View
|
|
218
|
+
|
|
219
|
+
Add rendering logic to your section's storefront view:
|
|
220
|
+
|
|
221
|
+
```erb
|
|
222
|
+
<% when 'Spree::PageBlocks::Quote' %>
|
|
223
|
+
<blockquote <%= block_attributes(block) %> class="text-<%= block.preferred_text_alignment %>">
|
|
224
|
+
<p class="text-xl italic"><%= block.text %></p>
|
|
225
|
+
<% if block.preferred_author_name.present? %>
|
|
226
|
+
<footer class="mt-4">
|
|
227
|
+
<cite>
|
|
228
|
+
<strong><%= block.preferred_author_name %></strong>
|
|
229
|
+
<% if block.preferred_author_title.present? %>
|
|
230
|
+
<br><span class="text-sm text-gray-500"><%= block.preferred_author_title %></span>
|
|
231
|
+
<% end %>
|
|
232
|
+
</cite>
|
|
233
|
+
</footer>
|
|
234
|
+
<% end %>
|
|
235
|
+
</blockquote>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Block with Links
|
|
239
|
+
|
|
240
|
+
To add link support to your block, include the `Spree::HasOneLink` concern:
|
|
241
|
+
|
|
242
|
+
```ruby
|
|
243
|
+
module Spree
|
|
244
|
+
module PageBlocks
|
|
245
|
+
class CallToAction < Spree::PageBlock
|
|
246
|
+
include Spree::HasOneLink
|
|
247
|
+
|
|
248
|
+
preference :button_style, :string, default: 'primary'
|
|
249
|
+
|
|
250
|
+
# Called when the link is destroyed
|
|
251
|
+
def link_destroyed(_link)
|
|
252
|
+
destroy if page_links_count.zero?
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Block with Image
|
|
260
|
+
|
|
261
|
+
Blocks automatically have an `asset` attachment available:
|
|
262
|
+
|
|
263
|
+
```ruby
|
|
264
|
+
# Check if image is attached
|
|
265
|
+
block.asset.attached?
|
|
266
|
+
|
|
267
|
+
# Display image in view
|
|
268
|
+
<% if block.asset.attached? %>
|
|
269
|
+
<%= spree_image_tag block.asset, width: 400, height: 300 %>
|
|
270
|
+
<% end %>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Key Methods
|
|
274
|
+
|
|
275
|
+
| Method | Description |
|
|
276
|
+
|--------|-------------|
|
|
277
|
+
| `display_name` | Name shown in Page Builder sidebar |
|
|
278
|
+
| `icon_name` | Icon from [Tabler Icons](https://tabler.io/icons) |
|
|
279
|
+
| `form_partial_name` | Name of the admin form partial |
|
|
280
|
+
|
|
281
|
+
## Related Documentation
|
|
282
|
+
|
|
283
|
+
- [Sections](/developer/storefront/sections) - Parent containers for blocks
|
|
284
|
+
- [Links](/developer/storefront/links) - Adding links to blocks
|
|
285
|
+
- [Media](/developer/core-concepts/media) - Working with images
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Custom CSS for Spree Storefront"
|
|
3
|
+
sidebarTitle: "Custom CSS"
|
|
4
|
+
description: "Learn how to add custom CSS stylesheets to your Spree storefront"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Spree Storefront is built on top of [Tailwind CSS 4](https://tailwindcss.com/). After installing Spree you should find a main CSS file:
|
|
8
|
+
|
|
9
|
+
* [app/assets/tailwind/application.css](https://github.com/spree/spree/blob/main/storefront/lib/generators/spree/storefront/install/templates/application.css) - This is the main CSS file that imports Tailwind and adds storefront styles
|
|
10
|
+
|
|
11
|
+
If you're missing this file, or migrating from a previous version of Spree, you can generate it using the following command:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
bin/rails g spree:storefront:install
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
> **INFO:** Tailwind 4 uses a CSS-first configuration approach. There's no `tailwind.config.js` file - all configuration is done directly in CSS using the `@theme` directive.
|
|
18
|
+
|
|
19
|
+
## Basic Structure
|
|
20
|
+
|
|
21
|
+
Your [application.css](https://github.com/spree/spree/blob/main/storefront/lib/generators/spree/storefront/install/templates/application.css) file should look something like this:
|
|
22
|
+
|
|
23
|
+
```css app/assets/tailwind/application.css
|
|
24
|
+
@import "tailwindcss";
|
|
25
|
+
|
|
26
|
+
@theme {
|
|
27
|
+
/* Theme customizations go here */
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* Your custom styles */
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Importing Additional CSS Files
|
|
34
|
+
|
|
35
|
+
Create a new CSS file in the `app/assets/stylesheets` directory:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
touch app/assets/tailwind/my_custom_styles.css
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
In the `my_custom_styles.css` file, add your styles:
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
.my-custom-class {
|
|
45
|
+
color: red;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Then import it in your `application.css` file:
|
|
50
|
+
|
|
51
|
+
```css app/assets/tailwind/application.css
|
|
52
|
+
@import "tailwindcss";
|
|
53
|
+
@import "my_custom_styles.css"; /* [!code ++] */
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Importing 3rd Party CSS Libraries
|
|
57
|
+
|
|
58
|
+
You can import a 3rd party CSS library directly from a CDN:
|
|
59
|
+
|
|
60
|
+
```css app/assets/tailwind/application.css
|
|
61
|
+
@import "tailwindcss";
|
|
62
|
+
@import url("https://esm.sh/swiper@11.2.2/swiper-bundle.min.css"); /* [!code ++] */
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## CSS Variables
|
|
66
|
+
|
|
67
|
+
Spree Storefront uses CSS variables that are automatically injected into the page. This allows store owners to change colors, fonts, etc. from the admin dashboard via Page Builder.
|
|
68
|
+
|
|
69
|
+
The default variables look like this:
|
|
70
|
+
|
|
71
|
+
```css app/assets/tailwind/application.css
|
|
72
|
+
:root {
|
|
73
|
+
--primary: #000000;
|
|
74
|
+
--accent: #F0EFE9;
|
|
75
|
+
--danger: #C73528;
|
|
76
|
+
--success: #00C773;
|
|
77
|
+
--neutral: #999999;
|
|
78
|
+
|
|
79
|
+
--background: #FFFFFF;
|
|
80
|
+
--text: #000000;
|
|
81
|
+
|
|
82
|
+
--border-default-color: #E9E7DC;
|
|
83
|
+
--border-default-width: 1px;
|
|
84
|
+
--border-default-radius: 6px;
|
|
85
|
+
|
|
86
|
+
--button: #000000;
|
|
87
|
+
--button-rgb: 0, 0, 0;
|
|
88
|
+
--button-text: #ffffff;
|
|
89
|
+
--button-border-radius: 100px;
|
|
90
|
+
--button-border-width: 1px;
|
|
91
|
+
--button-border-color: ;
|
|
92
|
+
|
|
93
|
+
--button-hover: #000000;
|
|
94
|
+
--button-hover-text: #ffffff;
|
|
95
|
+
|
|
96
|
+
--secondary-button: #FFFFFF;
|
|
97
|
+
--secondary-button-text: #000000;
|
|
98
|
+
--secondary-button-hover: #000000;
|
|
99
|
+
--secondary-button-hover-text: #FFFFFF;
|
|
100
|
+
|
|
101
|
+
--input: #E9E7DC;
|
|
102
|
+
--input-bg: #ffffff;
|
|
103
|
+
--input-text: #6b7280;
|
|
104
|
+
--input-focus-bg: #ffffff;
|
|
105
|
+
--input-border-radius: 8px;
|
|
106
|
+
|
|
107
|
+
--neutral-50: #F3F3F3;
|
|
108
|
+
--neutral-100: #EAEAEA;
|
|
109
|
+
--neutral-200: #D4D4D4;
|
|
110
|
+
--neutral-300: #B3B3B3;
|
|
111
|
+
--neutral-400: #999999;
|
|
112
|
+
--neutral-500: #808080;
|
|
113
|
+
--neutral-600: #666666;
|
|
114
|
+
--neutral-700: #4D4D4D;
|
|
115
|
+
--neutral-800: #333333;
|
|
116
|
+
--neutral-900: #1A1A1A;
|
|
117
|
+
--accent-100: #FBFAF8;
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
They are defined in the [app/views/themes/default/spree/shared/_css_variables.html.erb](https://github.com/spree/spree/blob/main/storefront/app/views/themes/default/spree/shared/_css_variables.html.erb) file which should be present in your theme.
|
|
122
|
+
|
|
123
|
+
## Customizing with @theme
|
|
124
|
+
|
|
125
|
+
Tailwind 4 uses the `@theme` directive for customizations. You can extend or override the default theme:
|
|
126
|
+
|
|
127
|
+
```css app/assets/tailwind/application.css
|
|
128
|
+
@import "tailwindcss";
|
|
129
|
+
|
|
130
|
+
@theme {
|
|
131
|
+
/* Add custom colors using Spree's CSS variables */
|
|
132
|
+
--color-primary: var(--primary);
|
|
133
|
+
--color-accent: var(--accent);
|
|
134
|
+
--color-danger: var(--danger);
|
|
135
|
+
--color-success: var(--success);
|
|
136
|
+
|
|
137
|
+
/* Add custom fonts */
|
|
138
|
+
--font-display: "Playfair Display", serif;
|
|
139
|
+
|
|
140
|
+
/* Add custom spacing */
|
|
141
|
+
--spacing-18: 4.5rem;
|
|
142
|
+
|
|
143
|
+
/* Add custom border radius */
|
|
144
|
+
--radius-button: var(--button-border-radius);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Then use them in your templates:
|
|
149
|
+
|
|
150
|
+
```erb
|
|
151
|
+
<div class="bg-primary text-white font-display p-18 rounded-button">
|
|
152
|
+
Custom styled content
|
|
153
|
+
</div>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Overriding Section Styles
|
|
157
|
+
|
|
158
|
+
Each section has CSS classes you can target to customize its appearance:
|
|
159
|
+
|
|
160
|
+
```css
|
|
161
|
+
/* Section container classes follow the pattern: section-{section-type} */
|
|
162
|
+
.section-image-with-text {
|
|
163
|
+
/* Custom styles for Image with Text section */
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.section-featured-taxon {
|
|
167
|
+
/* Custom styles for Featured Taxon section */
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* Block-specific styles within sections */
|
|
171
|
+
.image-with-text--heading {
|
|
172
|
+
font-family: serif;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.rich-text--text {
|
|
176
|
+
line-height: 1.8;
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Using Tailwind Utility Classes
|
|
181
|
+
|
|
182
|
+
You can use Tailwind utility classes directly in your templates:
|
|
183
|
+
|
|
184
|
+
```erb
|
|
185
|
+
<div class="flex items-center gap-4 p-6 bg-accent rounded-lg">
|
|
186
|
+
<%= product.name %>
|
|
187
|
+
</div>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Arbitrary Values
|
|
191
|
+
|
|
192
|
+
Tailwind 4 supports arbitrary values for one-off customizations:
|
|
193
|
+
|
|
194
|
+
```erb
|
|
195
|
+
<div class="p-[17px] bg-[#1a1a1a] text-[13px] grid-cols-[1fr_2fr]">
|
|
196
|
+
Custom values
|
|
197
|
+
</div>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Variant Modifiers
|
|
201
|
+
|
|
202
|
+
Use variant modifiers for responsive and state-based styles:
|
|
203
|
+
|
|
204
|
+
```erb
|
|
205
|
+
<div class="p-4 md:p-6 lg:p-8 hover:bg-accent active:scale-95">
|
|
206
|
+
Responsive and interactive
|
|
207
|
+
</div>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Adding Custom Utilities
|
|
211
|
+
|
|
212
|
+
You can add custom utilities using standard CSS with the `@utility` directive:
|
|
213
|
+
|
|
214
|
+
```css
|
|
215
|
+
@import "tailwindcss";
|
|
216
|
+
|
|
217
|
+
@utility content-auto {
|
|
218
|
+
content-visibility: auto;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@utility scrollbar-hidden {
|
|
222
|
+
scrollbar-width: none;
|
|
223
|
+
&::-webkit-scrollbar {
|
|
224
|
+
display: none;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Then use them like any other utility:
|
|
230
|
+
|
|
231
|
+
```erb
|
|
232
|
+
<div class="content-auto scrollbar-hidden">
|
|
233
|
+
<!-- Content -->
|
|
234
|
+
</div>
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Adding Custom Variants
|
|
238
|
+
|
|
239
|
+
Create custom variants with the `@variant` directive:
|
|
240
|
+
|
|
241
|
+
```css
|
|
242
|
+
@import "tailwindcss";
|
|
243
|
+
|
|
244
|
+
@variant pointer-coarse (@media (pointer: coarse));
|
|
245
|
+
@variant theme-dark (&:where([data-theme="dark"], [data-theme="dark"] *));
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Use them in your templates:
|
|
249
|
+
|
|
250
|
+
```erb
|
|
251
|
+
<button class="p-2 pointer-coarse:p-4 theme-dark:bg-gray-800">
|
|
252
|
+
Touch-friendly button
|
|
253
|
+
</button>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Related Documentation
|
|
257
|
+
|
|
258
|
+
- [Themes](/developer/storefront/themes) - Theme settings and colors
|
|
259
|
+
- [Custom JavaScript](/developer/storefront/custom-javascript) - Adding interactivity
|
|
260
|
+
- [Tailwind CSS 4 Documentation](https://tailwindcss.com/docs) - Official Tailwind docs
|