@spree/docs 0.1.252 → 0.1.253
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.
|
@@ -280,6 +280,10 @@ Completing a cart moves real money, so Spree is careful about it:
|
|
|
280
280
|
|
|
281
281
|
**Totals are worked out at the last moment.** The amount charged is calculated when the cart is completed, not taken from an earlier request — so a price or promotion that changed while the customer was reviewing can't lead to the wrong charge.
|
|
282
282
|
|
|
283
|
+
**The order keeps what the cart collected.** The customer, addresses, items, notes, purchase order number, tax identifier and the cart's `metadata` are all copied onto the order. When a checkout is split into one order per seller, every one of those orders receives the same copy. After that the cart and the order are independent — changing one never changes the other.
|
|
284
|
+
|
|
285
|
+
> **WARNING:** A customer can write a cart's `metadata` through the Store API, so once it is copied onto the order, treat those keys as customer input. Do not keep anything there that your own code later trusts, such as a fraud or approval flag.
|
|
286
|
+
|
|
283
287
|
If a cart can't be completed you get told why — a payment failure, or unmet [requirements](#checkout-requirements) — and the cart is left alone so the customer can fix it and try again.
|
|
284
288
|
|
|
285
289
|
## Abandoned carts
|
|
@@ -5,7 +5,7 @@ description: How Spree models orders — a permanent record created by completin
|
|
|
5
5
|
|
|
6
6
|
## Overview
|
|
7
7
|
|
|
8
|
-
An order is a placed purchase. It's created by completing a [Cart](carts.md) and holds its own copy of everything the customer agreed to — items, prices, taxes, discounts and delivery.
|
|
8
|
+
An order is a placed purchase. It's created by completing a [Cart](carts.md) and holds its own copy of everything the customer agreed to — items, prices, taxes, discounts and delivery. Anything your storefront stored in the cart's `metadata` is copied onto the order too, including onto every order of a checkout split between sellers.
|
|
9
9
|
|
|
10
10
|
```mermaid
|
|
11
11
|
erDiagram
|
|
@@ -41,6 +41,11 @@ Spree::Checkout::Registry.add_requirement(
|
|
|
41
41
|
While `satisfied:` returns false the cart reports the requirement and refuses to
|
|
42
42
|
complete. Its `code` is derived as `<field>_required` — `vat_number_required` here.
|
|
43
43
|
|
|
44
|
+
The storefront satisfies it by writing the value into the cart's `metadata`. When the
|
|
45
|
+
cart is completed, its `metadata` is copied onto the order — onto every order if the
|
|
46
|
+
checkout is split between sellers — so the VAT number is still there after placement as
|
|
47
|
+
`order.metadata['vat_number']`.
|
|
48
|
+
|
|
44
49
|
Pass `applicable:` to scope it. It is checked before `satisfied:`, so a requirement
|
|
45
50
|
that doesn't apply never appears at all:
|
|
46
51
|
|