Product fields, storefront flow, and CSRF.
Product field convention
On the product content type:
| Field key | Type | Purpose |
|---|---|---|
price_cents | number | Price in minor units (1999 = £19.99). Required unless stripe_price_id set. |
purchasable | boolean | Off hides buy button while entry stays public. |
stripe_price_id | text | Optional Stripe Price ID (price_…) — overrides ad-hoc price_cents. |
sku | text | Optional SKU on order line metadata. |
stock_qty | number | Optional stock. Empty = unlimited. Decremented when inventory tracking enabled. |
Creating a product
- Go to Content → Products (or your product type).
- Create entry with title, description, featured image.
- Set
price_centsandpurchasableon. - Set
stock_qtyif using inventory. - Publish.
Storefront
When commerce is enabled:
/shop— Product grid with live prices- Theme header shows Shop and Cart (n)
- Product archive
/{product-type-slug}shows prices and Add to cart on cards - Single product pages show Buy now and Add to cart when in stock
Checkout flows
| Action | Route | Notes |
|---|---|---|
| Buy now | POST /commerce/checkout | Single item Stripe Checkout |
| View cart | GET /commerce/cart | Update quantities, apply coupon |
| Add to cart | POST /commerce/cart/add | CSRF required |
| Cart checkout | POST /commerce/cart/checkout | Multi-item Stripe Checkout |
| Apply coupon | POST /commerce/cart/coupon | Apply or remove code |
All checkout POST routes require CSRF tokens from the storefront forms.
Success URL
/commerce/checkout/success?session_id=… triggers fulfillment (inventory, digital grants, emails, coupon redemption) if the webhook has not already processed the payment.
Buy now vs cart
Buy now skips the session cart for impulse purchases. Cart supports multiple items, coupons, and combined tax/shipping estimates before one Checkout session.
Troubleshooting
- CSRF error on checkout — Session expired; refresh page and retry.
- Coupon rejected — Expired, max uses reached, or cart contains stripe_price_id-only products.
- Out of stock at checkout — Another buyer completed purchase; refresh product page.