Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Updates to Spree::OrderGroup to properly display multi-seller order on Order Summary Page (#14877)
Kacper Mękarski8dbe607bdd0c
diff --git a/.changeset/order-group-summary.md b/.changeset/order-group-summary.mdnew file mode 100644index 0000000000..32e0975ffc--- /dev/null+++ b/.changeset/order-group-summary.md@@ -0,0 +1,8 @@+---+"@spree/sdk": minor+"@spree/admin-sdk": minor+---++`orders.get` now returns `Order | OrderGroup`. Called with the id of the cart a checkout was placed from, it returns the whole purchase: one order, or, when the checkout reached several sellers, the order group holding one order per seller. Narrow the result with `isOrderGroup` before reading order-only fields such as `items`. An order group now carries the same money summary as an order (delivery, discount, tax, fee, gift card and store credit totals, the amount still due) and its payments.++`store_credit_total` on carts, orders and order groups no longer includes what a gift card paid. That amount is reported only in `gift_card_total`, so a summary that shows both rows no longer deducts it twice. `amount_due` no longer subtracts store credit that has already been captured.diff --git a/.changeset/store-deprecated-fields.md b/.changeset/store-deprecated-fields.mdnew file mode 100644index 0000000000..7bafdfa9c1--- /dev/null+++ b/.changeset/store-deprecated-fields.md@@ -0,0 +1,5 @@+---+"@spree/sdk": patch+---++Stock locations bring back `country_iso` and `state_abbr`, and refunds bring back `reimbursement_id` (always `null`), all marked `@deprecated` until 6.1 so a 5.6 storefront keeps compiling. `AppliedPromotion`, `Fee`, `TaxLine` and `Delivery`, which carts, orders and their items already carry, are now exported from the package root.diff --git a/docs/api-reference/admin.yaml b/docs/api-reference/admin.yamlindex 7c31f62bff..1877f4867a 100644--- a/docs/api-reference/admin.yaml+++ b/docs/api-reference/admin.yaml@@ -16617,8 +16617,19 @@ paths:number: R1001email: [email protected]currency: USD- total: '0.00'item_total: '0.00'+ discount_total: '0.00'+ tax_total: '0.00'+ included_tax_total: '0.00'+ additional_tax_total: '0.00'+ delivery_total: '0.00'+ fee_total: '0.00'+ gift_card_total: '0.00'+ store_credit_total: '0.00'+ total: '0.00'+ amount_due: '0.00'+ covered_by_store_credit: false+ payments: []fulfillment_status:payment_status:completed_at: '2026-01-15T12:00:00.000Z'@@ -16633,7 +16644,6 @@ paths:store_owner_notification_delivered: falsecreated_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'- payments: []meta:page: 1limit: 25@@ -16713,18 +16723,18 @@ paths:payment_status:completed_at:item_total: '50.00'- adjustment_total: "-5.00"discount_total: "-5.00"tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '145.00'- gift_card_total: '0.00'- amount_due: '145.00'delivery_total: '100.00'fee_total: '0.00'+ gift_card_total: '0.00'store_credit_total: '0.00'+ total: '145.00'+ amount_due: '145.00'covered_by_store_credit: false+ adjustment_total: "-5.00"gift_card:market:id: mkt_UkLWZg9DAJ@@ -17577,18 +17587,18 @@ paths:payment_status:completed_at:item_total: '10.00'- adjustment_total: '0.00'discount_total: '0.00'tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '110.00'- gift_card_total: '0.00'- amount_due: '60.00'delivery_total: '100.00'fee_total: '0.00'+ gift_card_total: '0.00'store_credit_total: '50.00'+ total: '110.00'+ amount_due: '60.00'covered_by_store_credit: false+ adjustment_total: '0.00'gift_card:market:id: mkt_UkLWZg9DAJ@@ -17925,18 +17935,18 @@ paths:payment_status:completed_at:item_total: '0.00'- adjustment_total: '0.00'discount_total: '0.00'tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '0.00'- gift_card_total: '0.00'- amount_due: '0.00'delivery_total: '0.00'fee_total:+ gift_card_total: '0.00'store_credit_total: '0.00'+ total: '0.00'+ amount_due: '0.00'covered_by_store_credit: false+ adjustment_total: '0.00'gift_card:market:id: mkt_UkLWZg9DAJ@@ -18150,18 +18160,18 @@ paths:payment_status:completed_at:item_total: '0.00'- adjustment_total: '0.00'discount_total: '0.00'tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '0.00'- gift_card_total: '0.00'- amount_due: '0.00'delivery_total: '0.00'fee_total: '0.00'+ gift_card_total: '0.00'store_credit_total: '0.00'+ total: '0.00'+ amount_due: '0.00'covered_by_store_credit: false+ adjustment_total: '0.00'gift_card:market:id: mkt_UkLWZg9DAJ@@ -18306,18 +18316,18 @@ paths:payment_status:completed_at:item_total: '0.00'- adjustment_total: '0.00'discount_total: '0.00'tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '0.00'- gift_card_total: '0.00'- amount_due: '0.00'delivery_total: '0.00'fee_total:+ gift_card_total: '0.00'store_credit_total: '0.00'+ total: '0.00'+ amount_due: '0.00'covered_by_store_credit: false+ adjustment_total: '0.00'gift_card:market:id: mkt_UkLWZg9DAJ@@ -18452,18 +18462,18 @@ paths:payment_status: nonecompleted_at:item_total: '0.00'- adjustment_total: '0.00'discount_total: '0.00'tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '0.00'- gift_card_total: '0.00'- amount_due: '0.00'delivery_total: '0.00'fee_total: '0.00'+ gift_card_total: '0.00'store_credit_total: '0.00'+ total: '0.00'+ amount_due: '0.00'covered_by_store_credit: false+ adjustment_total: '0.00'gift_card:market:id: mkt_UkLWZg9DAJ@@ -18650,18 +18660,18 @@ paths:payment_status: paidcompleted_at: '2026-01-15T12:00:00.000Z'item_total: '10.00'- adjustment_total: '0.00'discount_total: '0.00'tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '110.00'- gift_card_total: '0.00'- amount_due: '0.00'delivery_total: '100.00'fee_total: '0.00'+ gift_card_total: '0.00'store_credit_total: '0.00'+ total: '110.00'+ amount_due: '0.00'covered_by_store_credit: false+ adjustment_total: '0.00'gift_card:market:id: mkt_UkLWZg9DAJ@@ -18828,18 +18838,18 @@ paths:payment_status: nonecompleted_at: '2026-01-15T12:00:00.000Z'item_total: '10.00'- adjustment_total: '0.00'discount_total: '0.00'tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '110.00'- gift_card_total: '0.00'- amount_due: '0.00'delivery_total: '100.00'fee_total: '0.00'+ gift_card_total: '0.00'store_credit_total: '0.00'+ total: '110.00'+ amount_due: '0.00'covered_by_store_credit: false+ adjustment_total: '0.00'gift_card:market:id: mkt_UkLWZg9DAJ@@ -18967,18 +18977,18 @@ paths:payment_status:completed_at: '2026-01-15T12:00:00.000Z'item_total: '10.00'- adjustment_total: '0.00'discount_total: '0.00'tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '110.00'- gift_card_total: '0.00'- amount_due: '110.00'delivery_total: '100.00'fee_total: '0.00'+ gift_card_total: '0.00'store_credit_total: '0.00'+ total: '110.00'+ amount_due: '110.00'covered_by_store_credit: false+ adjustment_total: '0.00'gift_card:market:id: mkt_UkLWZg9DAJ@@ -19100,18 +19110,18 @@ paths:payment_status:completed_at: '2026-01-15T12:00:00.000Z'item_total: '10.00'- adjustment_total: '0.00'discount_total: '0.00'tax_total: '0.00'included_tax_total: '0.00'additional_tax_total: '0.00'- total: '110.00'- gift_card_total: '0.00'- amount_due: '110.00'delivery_total: '100.00'fee_total: '0.00'+ gift_card_total: '0.00'store_credit_total: '0.00'+ total: '110.00'+ amount_due: '110.00'covered_by_store_credit: false+ adjustment_total: '0.00'gift_card:market:id: mkt_UkLWZg9DAJ@@ -52629,9 +52639,6 @@ components:item_total:type: stringnullable: true- adjustment_total:- type: string- nullable: truediscount_total:type: stringnullable: true@@ -52644,26 +52651,29 @@ components:additional_tax_total:type: stringnullable: true- total:+ delivery_total:type: stringnullable: true- gift_card_total:+ fee_total:type: stringnullable: true- amount_due:+ gift_card_total:type: stringnullable: true- delivery_total:+ store_credit_total:type: stringnullable: true- fee_total:+ total:type: stringnullable: true- store_credit_total:+ amount_due:type: stringnullable: truecovered_by_store_credit:type: boolean+ adjustment_total:+ type: string+ nullable: truecurrent_step:type: stringcompleted_steps:@@ -52736,18 +52746,18 @@ components:- warnings- coupon_code- item_total- - adjustment_total- discount_total- tax_total- included_tax_total- additional_tax_total- - total- - gift_card_total- - amount_due- delivery_total- fee_total+ - gift_card_total- store_credit_total+ - total+ - amount_due- covered_by_store_credit+ - adjustment_total- current_step- completed_steps- requirements@@ -58868,12 +58878,45 @@ components:- ZWL- ZWN- ZWR+ item_total:+ type: string+ nullable: true+ discount_total:+ type: string+ nullable: true+ tax_total:+ type: string+ nullable: true+ included_tax_total:+ type: string+ nullable: true+ additional_tax_total:+ type: string+ nullable: true+ delivery_total:+ type: string+ nullable: true+ fee_total:+ type: string+ nullable: true+ gift_card_total:+ type: string+ nullable: true+ store_credit_total:+ type: string+ nullable: truetotal:type: stringnullable: true- item_total:+ amount_due:type: stringnullable: true+ covered_by_store_credit:+ type: boolean+ payments:+ type: array+ items:+ "$ref": "#/components/schemas/Payment"fulfillment_status:type: stringnullable: true@@ -58932,17 +58975,24 @@ components:type: stringupdated_at:type: string- payments:- type: array- items:- "$ref": "#/components/schemas/Payment"required:- id- number- currency- - total- item_total+ - discount_total+ - tax_total+ - included_tax_total+ - additional_tax_total+ - delivery_total+ - fee_total+ - gift_card_total+ - store_credit_total+ - total+ - amount_due+ - covered_by_store_credit+ - payments- fulfillment_status- payment_status- completed_at@@ -58957,7 +59007,6 @@ components:- store_owner_notification_delivered- created_at- updated_at- - paymentsx-typelizer: trueOrderRoutingRule:type: object@@ -59250,8 +59299,6 @@ components:nullable: trueitem_total:type: string- adjustment_total:- type: stringdiscount_total:type: stringtax_total:@@ -59260,20 +59307,26 @@ components:type: stringadditional_tax_total:type: string- total:- type: string- gift_card_total:- type: string- amount_due:- type: stringdelivery_total:type: stringfee_total:type: string+ gift_card_total:+ type: stringstore_credit_total:type: string+ total:+ type: string+ amount_due:+ type: stringcovered_by_store_credit:type: boolean+ payments:+ type: array+ items:+ "$ref": "#/components/schemas/Payment"+ adjustment_total:+ type: stringitems:type: arrayitems:@@ -59282,10 +59335,6 @@ components:type: arrayitems:"$ref": "#/components/schemas/Fulfillment"- payments:- type: array- items:- "$ref": "#/components/schemas/Payment"billing_address:allOf:- "$ref": "#/components/schemas/Address"@@ -59482,18 +59531,18 @@ components:- payment_status- completed_at- item_total- - adjustment_total- discount_total- tax_total- included_tax_total- additional_tax_total- - total- - gift_card_total- - amount_due- delivery_total- fee_total+ - gift_card_total- store_credit_total+ - total+ - amount_due- covered_by_store_credit+ - adjustment_total- gift_card- market- external_referencesdiff --git a/docs/api-reference/store.yaml b/docs/api-reference/store.yamlindex 0c190efc3e..a5b496849a 100644--- a/docs/api-reference/store.yaml+++ b/docs/api-reference/store.yaml@@ -2190,8 +2190,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -2200,19 +2198,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '10.00'- display_amount_due: "$10.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '10.00'+ display_amount_due: "$10.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -2272,7 +2273,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -2311,8 +2311,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -2321,19 +2319,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '10.00'- display_amount_due: "$10.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '10.00'+ display_amount_due: "$10.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -2393,7 +2394,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -2503,8 +2503,6 @@ paths:coupon_code:item_total: '0.00'display_item_total: "$0.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -2513,19 +2511,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '0.00'- display_total: "$0.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '0.00'- display_amount_due: "$0.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '0.00'+ display_total: "$0.00"+ amount_due: '0.00'+ display_amount_due: "$0.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -2546,7 +2547,6 @@ paths:fees: []items: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -2664,8 +2664,6 @@ paths:coupon_code:item_total: '0.00'display_item_total: "$0.00"- adjustment_total: '17.00'- display_adjustment_total: "$17.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -2674,19 +2672,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '17.00'- display_total: "$17.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '17.00'- display_amount_due: "$17.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '17.00'display_fee_total: "$17.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '17.00'+ display_total: "$17.00"+ amount_due: '17.00'+ display_amount_due: "$17.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '17.00'+ display_adjustment_total: "$17.00"current_step: addresscompleted_steps: []requirements:@@ -2725,7 +2726,6 @@ paths:display_amount: "$12.00"items: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -2847,8 +2847,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -2857,19 +2855,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '10.00'- display_amount_due: "$10.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '10.00'+ display_amount_due: "$10.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -2925,7 +2926,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -3074,8 +3074,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -3084,19 +3082,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '10.00'- display_amount_due: "$10.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '10.00'+ display_amount_due: "$10.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: deliverycompleted_steps:- address@@ -3149,7 +3150,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments: []billing_address:id: addr_gbHJdmfrXBlabel:@@ -3306,8 +3306,6 @@ paths:completed_at: '2026-01-15T12:00:00.000Z'item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -3316,19 +3314,47 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '20.00'- display_total: "$20.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '20.00'- display_amount_due: "$20.00"delivery_total: '10.00'display_delivery_total: "$10.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '20.00'+ display_total: "$20.00"+ amount_due: '20.00'+ display_amount_due: "$20.00"covered_by_store_credit: false+ payments:+ - id: py_UkLWZg9DAJ+ payment_method_id: pm_UkLWZg9DAJ+ response_code: BGS-518d4ef9738e+ number: R1001-P1+ status: completed+ amount: '20.00'+ display_amount: "$20.00"+ source_type: credit_card+ source_id: card_UkLWZg9DAJ+ source:+ id: card_UkLWZg9DAJ+ brand: visa+ last4: '1111'+ month: 12+ year: 2027+ name: Spree Commerce+ default: false+ gateway_payment_profile_id:+ payment_method:+ id: pm_UkLWZg9DAJ+ name: Check 8+ description:+ type: check+ session_required: false+ source_required: false+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"discounts: []fees: []items:@@ -3411,6 +3437,8 @@ paths:country_name: United Statesstate_code: ALstate_text: AL+ country_iso: US+ state_abbr: ALpickup_ready_in_minutes:pickup_instructions:delivery_rates:@@ -3442,32 +3470,6 @@ paths:digital: falsepickup: falsepickup_point: false- payments:- - id: py_UkLWZg9DAJ- payment_method_id: pm_UkLWZg9DAJ- response_code: BGS-518d4ef9738e- number: R1001-P1- status: completed- amount: '20.00'- display_amount: "$20.00"- source_type: credit_card- source_id: card_UkLWZg9DAJ- source:- id: card_UkLWZg9DAJ- brand: visa- last4: '1111'- month: 12- year: 2027- name: Spree Commerce- default: false- gateway_payment_profile_id:- payment_method:- id: pm_UkLWZg9DAJ- name: Check 8- description:- type: check- session_required: false- source_required: falsebilling_address:id: addr_uw2YK1rnl0label:@@ -3628,8 +3630,6 @@ paths:coupon_code: big50item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -3638,19 +3638,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '10.00'- display_amount_due: "$10.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '10.00'+ display_amount_due: "$10.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -3706,7 +3709,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -3823,8 +3825,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -3833,19 +3833,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '10.00'- display_amount_due: "$10.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '10.00'+ display_amount_due: "$10.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -3901,7 +3904,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -4018,8 +4020,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -4028,19 +4028,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '20.00'- display_total: "$20.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '20.00'- display_amount_due: "$20.00"delivery_total: '10.00'display_delivery_total: "$10.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '20.00'+ display_total: "$20.00"+ amount_due: '20.00'+ display_amount_due: "$20.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: paymentcompleted_steps:- address@@ -4137,6 +4140,8 @@ paths:country_name: United Statesstate_code: ALstate_text: AL+ country_iso: US+ state_abbr: ALpickup_ready_in_minutes:pickup_instructions:delivery_rates:@@ -4168,7 +4173,6 @@ paths:digital: falsepickup: falsepickup_point: false- payments: []billing_address:shipping_address:id: addr_EfhxLZ9ck8@@ -4309,8 +4313,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -4319,19 +4321,47 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '10.00'- display_gift_card_total: "$10.00"- amount_due: '0.00'- display_amount_due: "$0.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"- store_credit_total: '10.00'- display_store_credit_total: "-$10.00"+ gift_card_total: '10.00'+ display_gift_card_total: "$10.00"+ store_credit_total: '0.00'+ display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '0.00'+ display_amount_due: "$0.00"covered_by_store_credit: true+ payments:+ - id: py_UkLWZg9DAJ+ payment_method_id: pm_UkLWZg9DAJ+ response_code: 1-SC-20260115120000000000+ number: cart_UkLWZg9DAJ-P1+ status: checkout+ amount: '10.00'+ display_amount: "$10.00"+ source_type: store_credit+ source_id: credit_UkLWZg9DAJ+ source:+ id: credit_UkLWZg9DAJ+ amount: '10.00'+ amount_used: '0.00'+ amount_remaining: '10.00'+ display_amount: "$10.00"+ display_amount_used: "$0.00"+ display_amount_remaining: "$10.00"+ currency: USD+ payment_method:+ id: pm_UkLWZg9DAJ+ name: Store Credit+ description:+ type: store_credit+ session_required: false+ source_required: true+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -4383,32 +4413,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments:- - id: py_UkLWZg9DAJ- payment_method_id: pm_UkLWZg9DAJ- response_code: 1-SC-20260115120000000000- number: cart_UkLWZg9DAJ-P1- status: checkout- amount: '10.00'- display_amount: "$10.00"- source_type: store_credit- source_id: credit_UkLWZg9DAJ- source:- id: credit_UkLWZg9DAJ- amount: '10.00'- amount_used: '0.00'- amount_remaining: '10.00'- display_amount: "$10.00"- display_amount_used: "$0.00"- display_amount_remaining: "$10.00"- currency: USD- payment_method:- id: pm_UkLWZg9DAJ- name: Store Credit- description:- type: store_credit- session_required: false- source_required: truebilling_address:shipping_address:payment_methods: []@@ -4549,8 +4553,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -4559,19 +4561,47 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '10.00'- display_amount_due: "$10.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '10.00'+ display_amount_due: "$10.00"covered_by_store_credit: false+ payments:+ - id: py_UkLWZg9DAJ+ payment_method_id: pm_UkLWZg9DAJ+ response_code: 1-SC-20260115120000000000+ number: cart_UkLWZg9DAJ-P1+ status: invalid+ amount: '10.00'+ display_amount: "$10.00"+ source_type: store_credit+ source_id: credit_UkLWZg9DAJ+ source:+ id: credit_UkLWZg9DAJ+ amount: '10.00'+ amount_used: '0.00'+ amount_remaining: '10.00'+ display_amount: "$10.00"+ display_amount_used: "$0.00"+ display_amount_remaining: "$10.00"+ currency: USD+ payment_method:+ id: pm_UkLWZg9DAJ+ name: Store Credit+ description:+ type: store_credit+ session_required: false+ source_required: true+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -4627,32 +4657,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments:- - id: py_UkLWZg9DAJ- payment_method_id: pm_UkLWZg9DAJ- response_code: 1-SC-20260115120000000000- number: cart_UkLWZg9DAJ-P1- status: invalid- amount: '10.00'- display_amount: "$10.00"- source_type: store_credit- source_id: credit_UkLWZg9DAJ- source:- id: credit_UkLWZg9DAJ- amount: '10.00'- amount_used: '0.00'- amount_remaining: '10.00'- display_amount: "$10.00"- display_amount_used: "$0.00"- display_amount_remaining: "$10.00"- currency: USD- payment_method:- id: pm_UkLWZg9DAJ- name: Store Credit- description:- type: store_credit- session_required: false- source_required: truebilling_address:shipping_address:payment_methods: []@@ -4766,8 +4770,6 @@ paths:coupon_code:item_total: '29.99'display_item_total: "$29.99"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -4776,19 +4778,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '29.99'- display_total: "$29.99"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '29.99'- display_amount_due: "$29.99"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '29.99'+ display_total: "$29.99"+ amount_due: '29.99'+ display_amount_due: "$29.99"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -4875,7 +4880,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -5013,8 +5017,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -5023,19 +5025,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '10.00'- display_amount_due: "$10.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '10.00'+ display_amount_due: "$10.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -5091,7 +5096,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -5193,8 +5197,6 @@ paths:coupon_code:item_total: '0.00'display_item_total: "$0.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -5203,19 +5205,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '0.00'- display_total: "$0.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '0.00'- display_amount_due: "$0.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '0.00'+ display_total: "$0.00"+ amount_due: '0.00'+ display_amount_due: "$0.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -5236,7 +5241,6 @@ paths:fees: []items: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -5800,8 +5804,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -5810,19 +5812,47 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '0.00'- display_amount_due: "$0.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '10.00'display_store_credit_total: "-$10.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '0.00'+ display_amount_due: "$0.00"covered_by_store_credit: true+ payments:+ - id: py_UkLWZg9DAJ+ payment_method_id: pm_UkLWZg9DAJ+ response_code: 1-SC-20260115120000000000+ number: cart_UkLWZg9DAJ-P1+ status: checkout+ amount: '10.00'+ display_amount: "$10.00"+ source_type: store_credit+ source_id: credit_UkLWZg9DAJ+ source:+ id: credit_UkLWZg9DAJ+ amount: '50.00'+ amount_used: '0.00'+ amount_remaining: '50.00'+ display_amount: "$50.00"+ display_amount_used: "$0.00"+ display_amount_remaining: "$50.00"+ currency: USD+ payment_method:+ id: pm_UkLWZg9DAJ+ name: Store Credit 5+ description: Store Credit+ type: store_credit+ session_required: false+ source_required: true+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -5874,32 +5904,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments:- - id: py_UkLWZg9DAJ- payment_method_id: pm_UkLWZg9DAJ- response_code: 1-SC-20260115120000000000- number: cart_UkLWZg9DAJ-P1- status: checkout- amount: '10.00'- display_amount: "$10.00"- source_type: store_credit- source_id: credit_UkLWZg9DAJ- source:- id: credit_UkLWZg9DAJ- amount: '50.00'- amount_used: '0.00'- amount_remaining: '50.00'- display_amount: "$50.00"- display_amount_used: "$0.00"- display_amount_remaining: "$50.00"- currency: USD- payment_method:- id: pm_UkLWZg9DAJ- name: Store Credit 5- description: Store Credit- type: store_credit- session_required: false- source_required: truebilling_address:shipping_address:payment_methods: []@@ -6006,8 +6010,6 @@ paths:coupon_code:item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -6016,19 +6018,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '10.00'- display_total: "$10.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '10.00'- display_amount_due: "$10.00"delivery_total: '0.00'display_delivery_total: "$0.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '10.00'+ display_total: "$10.00"+ amount_due: '10.00'+ display_amount_due: "$10.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"current_step: addresscompleted_steps: []requirements:@@ -6084,7 +6089,6 @@ paths:option_values: []digital_links: []fulfillments: []- payments: []billing_address:shipping_address:payment_methods: []@@ -6281,8 +6285,17 @@ paths:security:- api_key: []bearer_auth: []- description: Returns a single completed order by prefixed ID. Accessible via- JWT (authenticated users) or order token header (guests).+ description: |+ Returns a completed purchase. Accessible via JWT (authenticated users) or order token header (guests).++ Resolves three kinds of id: the order's own (`or_…`), the id of the cart it was placed from, and the+ id of an order group (`ogrp_…`). The cart's id is the handle a storefront keeps through checkout, so+ a confirmation page can ask what its cart became without having learned a new one.++ A checkout that reached several sellers divided into one order per seller, and the cart moved up to+ the group holding them — so that handle, and the group's own id, answer with the **order group**,+ with the per-seller orders nested inside it. Every other lookup answers with an **order**. The two+ are told apart by the id prefix (`ogrp_` vs `or_`), or by the presence of `orders`.x-codeSamples:- lang: javascriptlabel: Spree SDK@@ -6316,7 +6329,8 @@ paths:- name: idin: pathrequired: true- description: Order prefixed ID+ description: Prefixed ID of the order, of the cart it was placed from, or+ of its order groupschema:type: string- name: x-spree-token@@ -6369,8 +6383,6 @@ paths:completed_at: '2026-01-15T12:00:00.000Z'item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '12.00'- display_adjustment_total: "$12.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -6379,19 +6391,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '122.00'- display_total: "$122.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '122.00'- display_amount_due: "$122.00"delivery_total: '100.00'display_delivery_total: "$100.00"fee_total: '12.00'display_fee_total: "$12.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '122.00'+ display_total: "$122.00"+ amount_due: '122.00'+ display_amount_due: "$122.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '12.00'+ display_adjustment_total: "$12.00"discounts: []fees:- id: fee_UkLWZg9DAJ@@ -6490,6 +6505,8 @@ paths:country_name: United Statesstate_code: ALstate_text: AL+ country_iso: US+ state_abbr: ALpickup_ready_in_minutes:pickup_instructions:delivery_rates:@@ -6521,7 +6538,6 @@ paths:digital: falsepickup: falsepickup_point: false- payments: []billing_address:id: addr_UkLWZg9DAJlabel:@@ -7723,8 +7739,6 @@ paths:completed_at: '2026-01-15T12:00:00.000Z'item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -7733,19 +7747,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '110.00'- display_total: "$110.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '110.00'- display_amount_due: "$110.00"delivery_total: '100.00'display_delivery_total: "$100.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '110.00'+ display_total: "$110.00"+ amount_due: '110.00'+ display_amount_due: "$110.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"discounts: []fees: []items:@@ -7837,6 +7854,8 @@ paths:country_name: United Statesstate_code: ALstate_text: AL+ country_iso: US+ state_abbr: ALpickup_ready_in_minutes:pickup_instructions:delivery_rates:@@ -7868,7 +7887,6 @@ paths:digital: falsepickup: falsepickup_point: false- payments: []billing_address:id: addr_EfhxLZ9ck8label:@@ -8047,8 +8065,6 @@ paths:completed_at: '2026-01-15T12:00:00.000Z'item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -8056,20 +8072,23 @@ paths:included_tax_total: '0.00'display_included_tax_total: "$0.00"additional_tax_total: '0.00'- display_additional_tax_total: "$0.00"- total: '110.00'- display_total: "$110.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '110.00'- display_amount_due: "$110.00"+ display_additional_tax_total: "$0.00"delivery_total: '100.00'display_delivery_total: "$100.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '110.00'+ display_total: "$110.00"+ amount_due: '110.00'+ display_amount_due: "$110.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"discounts: []fees: []items:@@ -8161,6 +8180,8 @@ paths:country_name: United Statesstate_code: ALstate_text: AL+ country_iso: US+ state_abbr: ALpickup_ready_in_minutes:pickup_instructions:delivery_rates:@@ -8192,7 +8213,6 @@ paths:digital: falsepickup: falsepickup_point: false- payments: []billing_address:id: addr_EfhxLZ9ck8label:@@ -12333,8 +12353,6 @@ paths:completed_at: '2026-01-15T12:00:00.000Z'item_total: '10.00'display_item_total: "$10.00"- adjustment_total: '0.00'- display_adjustment_total: "$0.00"discount_total: '0.00'display_discount_total: "$0.00"tax_total: '0.00'@@ -12343,19 +12361,22 @@ paths:display_included_tax_total: "$0.00"additional_tax_total: '0.00'display_additional_tax_total: "$0.00"- total: '110.00'- display_total: "$110.00"- gift_card_total: '0.00'- display_gift_card_total: "$0.00"- amount_due: '110.00'- display_amount_due: "$110.00"delivery_total: '100.00'display_delivery_total: "$100.00"fee_total: '0.00'display_fee_total: "$0.00"+ gift_card_total: '0.00'+ display_gift_card_total: "$0.00"store_credit_total: '0.00'display_store_credit_total: "$0.00"+ total: '110.00'+ display_total: "$110.00"+ amount_due: '110.00'+ display_amount_due: "$110.00"covered_by_store_credit: false+ payments: []+ adjustment_total: '0.00'+ display_adjustment_total: "$0.00"discounts: []fees: []items:@@ -12446,6 +12467,8 @@ paths:country_name: United Statesstate_code: ALstate_text: AL+ country_iso: US+ state_abbr: ALpickup_ready_in_minutes:pickup_instructions:delivery_rates:@@ -12477,7 +12500,6 @@ paths:digital: falsepickup: falsepickup_point: false- payments: []billing_address:id: addr_EfhxLZ9ck8label:@@ -12810,6 +12832,8 @@ paths:country_name: United Statesstate_code: ALstate_text: AL+ country_iso: US+ state_abbr: ALpickup_ready_in_minutes:pickup_instructions:"/api/v3/store/customers/me/digital_links":@@ -14055,12 +14079,6 @@ components:display_item_total:type: stringnullable: true- adjustment_total:- type: string- nullable: true- display_adjustment_total:- type: string- nullable: truediscount_total:type: stringnullable: true@@ -14085,44 +14103,54 @@ components:display_additional_tax_total:type: stringnullable: true- total:+ delivery_total:type: stringnullable: true- display_total:+ display_delivery_total:type: stringnullable: true- gift_card_total:+ fee_total:type: stringnullable: true- display_gift_card_total:+ display_fee_total:type: stringnullable: true- amount_due:+ gift_card_total:type: stringnullable: true- display_amount_due:+ display_gift_card_total:type: stringnullable: true- delivery_total:+ store_credit_total:type: stringnullable: true- display_delivery_total:+ display_store_credit_total:type: stringnullable: true- fee_total:+ total:type: stringnullable: true- display_fee_total:+ display_total:type: stringnullable: true- store_credit_total:+ amount_due:type: stringnullable: true- display_store_credit_total:+ display_amount_due:type: stringnullable: truecovered_by_store_credit:type: boolean+ payments:+ type: array+ items:+ "$ref": "#/components/schemas/Payment"+ adjustment_total:+ type: string+ nullable: true+ display_adjustment_total:+ type: string+ nullable: truecurrent_step:type: stringcompleted_steps:@@ -14164,10 +14192,6 @@ components:type: arrayitems:"$ref": "#/components/schemas/Fulfillment"- payments:- type: array- items:- "$ref": "#/components/schemas/Payment"billing_address:allOf:- "$ref": "#/components/schemas/Address"@@ -14210,8 +14234,6 @@ components:- coupon_code- item_total- display_item_total- - adjustment_total- - display_adjustment_total- discount_total- display_discount_total- tax_total@@ -14220,19 +14242,22 @@ components:- display_included_tax_total- additional_tax_total- display_additional_tax_total- - total- - display_total- - gift_card_total- - display_gift_card_total- - amount_due- - display_amount_due- delivery_total- display_delivery_total- fee_total- display_fee_total+ - gift_card_total+ - display_gift_card_total- store_credit_total- display_store_credit_total+ - total+ - display_total+ - amount_due+ - display_amount_due- covered_by_store_credit+ - payments+ - adjustment_total+ - display_adjustment_total- current_step- completed_steps- requirements@@ -14245,7 +14270,6 @@ components:- fees- items- fulfillments- - payments- billing_address- shipping_address- payment_methods@@ -18091,18 +18115,78 @@ components:- ZWL- ZWN- ZWR+ item_total:+ type: string+ nullable: true+ display_item_total:+ type: string+ nullable: true+ discount_total:+ type: string+ nullable: true+ display_discount_total:+ type: string+ nullable: true+ tax_total:+ type: string+ nullable: true+ display_tax_total:+ type: string+ nullable: true+ included_tax_total:+ type: string+ nullable: true+ display_included_tax_total:+ type: string+ nullable: true+ additional_tax_total:+ type: string+ nullable: true+ display_additional_tax_total:+ type: string+ nullable: true+ delivery_total:+ type: string+ nullable: true+ display_delivery_total:+ type: string+ nullable: true+ fee_total:+ type: string+ nullable: true+ display_fee_total:+ type: string+ nullable: true+ gift_card_total:+ type: string+ nullable: true+ display_gift_card_total:+ type: string+ nullable: true+ store_credit_total:+ type: string+ nullable: true+ display_store_credit_total:+ type: string+ nullable: truetotal:type: stringnullable: truedisplay_total:type: stringnullable: true- item_total:+ amount_due:type: stringnullable: true- display_item_total:+ display_amount_due:type: stringnullable: true+ covered_by_store_credit:+ type: boolean+ payments:+ type: array+ items:+ "$ref": "#/components/schemas/Payment"fulfillment_status:type: stringnullable: true@@ -18148,10 +18232,30 @@ components:- number- currency- - total- - display_total- item_total- display_item_total+ - discount_total+ - display_discount_total+ - tax_total+ - display_tax_total+ - included_tax_total+ - display_included_tax_total+ - additional_tax_total+ - display_additional_tax_total+ - delivery_total+ - display_delivery_total+ - fee_total+ - display_fee_total+ - gift_card_total+ - display_gift_card_total+ - store_credit_total+ - display_store_credit_total+ - total+ - display_total+ - amount_due+ - display_amount_due+ - covered_by_store_credit+ - payments- fulfillment_status- payment_status- completed_at@@ -18423,12 +18527,6 @@ components:display_item_total:type: stringnullable: true- adjustment_total:- type: string- nullable: true- display_adjustment_total:- type: string- nullable: truediscount_total:type: stringnullable: true@@ -18453,44 +18551,54 @@ components:display_additional_tax_total:type: stringnullable: true- total:+ delivery_total:type: stringnullable: true- display_total:+ display_delivery_total:type: stringnullable: true- gift_card_total:+ fee_total:type: stringnullable: true- display_gift_card_total:+ display_fee_total:type: stringnullable: true- amount_due:+ gift_card_total:type: stringnullable: true- display_amount_due:+ display_gift_card_total:type: stringnullable: true- delivery_total:+ store_credit_total:type: stringnullable: true- display_delivery_total:+ display_store_credit_total:type: stringnullable: true- fee_total:+ total:type: stringnullable: true- display_fee_total:+ display_total:type: stringnullable: true- store_credit_total:+ amount_due:type: stringnullable: true- display_store_credit_total:+ display_amount_due:type: stringnullable: truecovered_by_store_credit:type: boolean+ payments:+ type: array+ items:+ "$ref": "#/components/schemas/Payment"+ adjustment_total:+ type: string+ nullable: true+ display_adjustment_total:+ type: string+ nullable: truediscounts:type: arrayitems:@@ -18507,10 +18615,6 @@ components:type: arrayitems:"$ref": "#/components/schemas/Fulfillment"- payments:- type: array- items:- "$ref": "#/components/schemas/Payment"billing_address:allOf:- "$ref": "#/components/schemas/Address"@@ -18551,8 +18655,6 @@ components:- completed_at- item_total- display_item_total- - adjustment_total- - display_adjustment_total- discount_total- display_discount_total- tax_total@@ -18561,24 +18663,26 @@ components:- display_included_tax_total- additional_tax_total- display_additional_tax_total- - total- - display_total- - gift_card_total- - display_gift_card_total- - amount_due- - display_amount_due- delivery_total- display_delivery_total- fee_total- display_fee_total+ - gift_card_total+ - display_gift_card_total- store_credit_total- display_store_credit_total+ - total+ - display_total+ - amount_due+ - display_amount_due- covered_by_store_credit+ - payments+ - adjustment_total+ - display_adjustment_total- discounts- fees- items- fulfillments- - payments- billing_address- shipping_address- gift_card@@ -20066,6 +20170,10 @@ components:originator_type:type: stringnullable: true+ reimbursement_id:+ type: string+ nullable: true+ deprecated: truerequired:- id- transaction_id@@ -20074,6 +20182,7 @@ components:- refund_reason_id- originator_id- originator_type+ - reimbursement_idx-typelizer: trueReturnLineItem:type: object@@ -20641,6 +20750,14 @@ components:state_text:type: stringnullable: true+ country_iso:+ type: string+ nullable: true+ deprecated: true+ state_abbr:+ type: string+ nullable: true+ deprecated: truepickup_ready_in_minutes:type: numbernullable: true@@ -20657,6 +20774,8 @@ components:- country_name- state_code- state_text+ - country_iso+ - state_abbr- pickup_ready_in_minutes- pickup_instructionsx-typelizer: truediff --git a/docs/developer/customization/email-variables.mdx b/docs/developer/customization/email-variables.mdxindex d01cae3589..c5333a327f 100644--- a/docs/developer/customization/email-variables.mdx+++ b/docs/developer/customization/email-variables.mdx@@ -47,7 +47,7 @@ Each object's fields, and the fields of the objects nested in it. Format an amou### `order`-- `order`: `id`, `market_id`, `withdrawal_period_ends_at`, `within_withdrawal_period`, `cart_id`, `channel_id`, `company_id`, `company_name`, `po_document_filename`, `po_document_byte_size`, `number`, `email`, `customer_note`, `po_number`, `currency`, `locale`, `total_quantity`, `coupon_code`, `fulfillment_status`, `payment_status`, `completed_at`, `item_total`, `display_item_total`, `adjustment_total`, `display_adjustment_total`, `discount_total`, `display_discount_total`, `tax_total`, `display_tax_total`, `included_tax_total`, `display_included_tax_total`, `additional_tax_total`, `display_additional_tax_total`, `total`, `display_total`, `gift_card_total`, `display_gift_card_total`, `amount_due`, `display_amount_due`, `delivery_total`, `display_delivery_total`, `fee_total`, `display_fee_total`, `store_credit_total`, `display_store_credit_total`, `covered_by_store_credit`, `customer_name`, `total_minus_store_credits`, `display_total_minus_store_credits`+- `order`: `id`, `market_id`, `withdrawal_period_ends_at`, `within_withdrawal_period`, `cart_id`, `channel_id`, `company_id`, `company_name`, `po_document_filename`, `po_document_byte_size`, `number`, `email`, `customer_note`, `po_number`, `currency`, `locale`, `total_quantity`, `coupon_code`, `fulfillment_status`, `payment_status`, `completed_at`, `item_total`, `display_item_total`, `discount_total`, `display_discount_total`, `tax_total`, `display_tax_total`, `included_tax_total`, `display_included_tax_total`, `additional_tax_total`, `display_additional_tax_total`, `delivery_total`, `display_delivery_total`, `fee_total`, `display_fee_total`, `gift_card_total`, `display_gift_card_total`, `store_credit_total`, `display_store_credit_total`, `total`, `display_total`, `amount_due`, `display_amount_due`, `covered_by_store_credit`, `adjustment_total`, `display_adjustment_total`, `customer_name`, `total_minus_store_credits`, `display_total_minus_store_credits`- `order.discounts`: `id`, `promotion_id`, `name`, `description`, `code`, `amount`, `display_amount`- `order.fees`: `id`, `label`, `kind`, `line_item_id`, `fulfillment_id`, `amount`, `display_amount`- `order.items`: `id`, `variant_id`, `seller_id`, `preorder`, `preorder_ships_at`, `quantity`, `currency`, `name`, `slug`, `options_text`, `price`, `display_price`, `total`, `display_total`, `adjustment_total`, `display_adjustment_total`, `additional_tax_total`, `display_additional_tax_total`, `included_tax_total`, `display_included_tax_total`, `discount_total`, `display_discount_total`, `pre_tax_amount`, `display_pre_tax_amount`, `discounted_amount`, `display_discounted_amount`, `display_compare_at_amount`, `compare_at_amount`, `url`, `image_url`, `sku`, `amount`, `display_amount`@@ -70,9 +70,11 @@ Each object's fields, and the fields of the objects nested in it. Format an amou### `order_group`-- `order_group`: `id`, `number`, `email`, `currency`, `total`, `display_total`, `item_total`, `display_item_total`, `fulfillment_status`, `payment_status`, `completed_at`, `customer_name`, `total_minus_store_credits`, `display_total_minus_store_credits`, `po_number`, `order_count`, `display_delivery_total`, `delivery_total`, `additional_tax_total`, `display_additional_tax_total`, `gift_card_total`, `display_gift_card_total`+- `order_group`: `id`, `number`, `email`, `currency`, `item_total`, `display_item_total`, `discount_total`, `display_discount_total`, `tax_total`, `display_tax_total`, `included_tax_total`, `display_included_tax_total`, `additional_tax_total`, `display_additional_tax_total`, `delivery_total`, `display_delivery_total`, `fee_total`, `display_fee_total`, `gift_card_total`, `display_gift_card_total`, `store_credit_total`, `display_store_credit_total`, `total`, `display_total`, `amount_due`, `display_amount_due`, `covered_by_store_credit`, `fulfillment_status`, `payment_status`, `completed_at`, `customer_name`, `total_minus_store_credits`, `display_total_minus_store_credits`, `po_number`, `order_count`- `order_group.billing_address`: `id`, `label`, `first_name`, `last_name`, `full_name`, `address1`, `address2`, `postal_code`, `city`, `phone`, `company`, `country_name`, `country_code`, `state_text`, `state_code`, `quick_checkout`, `is_default_billing`, `is_default_shipping`, `state_abbr`, `country_iso`, `state_name`- `order_group.shipping_address`: `id`, `label`, `first_name`, `last_name`, `full_name`, `address1`, `address2`, `postal_code`, `city`, `phone`, `company`, `country_name`, `country_code`, `state_text`, `state_code`, `quick_checkout`, `is_default_billing`, `is_default_shipping`, `state_abbr`, `country_iso`, `state_name`+- `order_group.payments`: `id`, `payment_method_id`, `response_code`, `number`, `status`, `amount`, `display_amount`, `source_type`, `source_id`, `source`+- `order_group.payments.payment_method`: `id`, `name`, `description`, `type`, `session_required`, `source_required`- `order_group.items`: `id`, `variant_id`, `seller_id`, `preorder`, `preorder_ships_at`, `quantity`, `currency`, `name`, `slug`, `options_text`, `price`, `display_price`, `total`, `display_total`, `adjustment_total`, `display_adjustment_total`, `additional_tax_total`, `display_additional_tax_total`, `included_tax_total`, `display_included_tax_total`, `discount_total`, `display_discount_total`, `pre_tax_amount`, `display_pre_tax_amount`, `discounted_amount`, `display_discounted_amount`, `display_compare_at_amount`, `compare_at_amount`, `url`, `image_url`, `sku`, `amount`, `display_amount`- `order_group.items.option_values`: `id`, `option_type_id`, `name`, `label`, `position`, `color_code`, `option_type_name`, `option_type_label`, `image_url`- `order_group.promotion_discounts`: `label`, `display_amount`, `amount`diff --git a/docs/developer/sdk/store/cart-checkout.mdx b/docs/developer/sdk/store/cart-checkout.mdxindex e8578f1708..54be3ffebb 100644--- a/docs/developer/sdk/store/cart-checkout.mdx+++ b/docs/developer/sdk/store/cart-checkout.mdx@@ -188,7 +188,7 @@ The cart and order responses break the amount the customer pays into these total- `fee_total` — every [fee](#fees-and-duties) on the cart, duties included- `tax_total` — tax on items, delivery and taxable fees- `total` — what the order costs: items, delivery, fees and tax, less discounts-- `store_credit_total` / `gift_card_total` — store credit or gift card value applied against the total+- `store_credit_total` / `gift_card_total` — store credit and gift card value applied against the total, each counted once (a gift card is not part of `store_credit_total`)- `amount_due` — what is left to pay after store credit and gift cards- `covered_by_store_credit` — boolean, whether the order is fully covered by store credit- `gift_card` — associated gift card (if applicable)diff --git a/docs/developer/upgrades/5.6-to-6.0.mdx b/docs/developer/upgrades/5.6-to-6.0.mdxindex 5f6857f797..5ea5a43c9d 100644--- a/docs/developer/upgrades/5.6-to-6.0.mdx+++ b/docs/developer/upgrades/5.6-to-6.0.mdx@@ -363,6 +363,8 @@ The full address surface is shared by Cart and Order through `Spree::Purchase::A| Removed from the Admin and Seller APIs | Use ||---|---|| Address `country_iso`, `state_abbr` (read and write) | `country_code`, `state_code` |+| Stock location `country_iso`, `state_abbr` | `country_code`, `state_code` |+| Refund `reimbursement_id` | `originator_id`, `originator_type` || Address `zipcode` (write) | `postal_code` || Admin cart `number` | `id` || Admin market `country_isos` | `country_codes` |@@ -1093,6 +1095,8 @@ A storefront built on the Store API and `@spree/sdk`, such as the [Spree storefr| A property that "does not exist" in a `…Params` type | Request types now list exactly what the endpoint accepts | [Request types](#request-types-match-the-api) || `ProductSort`, or a filter key | List filters and sort are typed | [List filters and sort](#list-filters-and-sort-are-typed) || `number` is not assignable to `string` in a filter or amount | Money is a decimal string everywhere | Send `'20.00'`, not `20` ([Money](#money), [store credit](#store-credit-amounts-are-decimal-strings)) |+| `name` or `description` "does not exist" on `Discount` | `Discount` now types the discount rows on items and fulfillments. The `discounts` list on carts and orders is unchanged and is typed `AppliedPromotion` | Import `AppliedPromotion` for `cart.discounts` and `order.discounts` |+| A property that "does not exist" on `OrderGroup` | Completing a cart, or reading an order by its cart id, can return an order group | [Completing a cart can return an order group](#completing-a-cart-can-return-an-order-group) |### List filters and sort are typed@@ -1120,7 +1124,7 @@ Each `list()` method now takes the filters and sort fields its endpoint accepts.### Completing a cart can return an order group-`carts.complete()` returns `Order | OrderGroup`. In a marketplace, a cart holding several sellers' goods divides into one order per seller and returns the group. Narrow the result with `isOrderGroup` before reading order fields:+`carts.complete()` returns `Order | OrderGroup`. In a marketplace, a cart holding several sellers' goods divides into one order per seller and returns the group. `orders.get()` does the same when given the cart's id, which is what an order confirmation page usually holds. Narrow the result with `isOrderGroup` before reading order fields:```tsimport { isOrderGroup } from '@spree/sdk'@@ -1129,6 +1133,12 @@ const result = await client.carts.complete(cartId)const orders = isOrderGroup(result) ? result.orders : [result]```+An order group carries the same totals as an order (`item_total`, `delivery_total`, `discount_total`, `tax_total`, `fee_total`, `gift_card_total`, `store_credit_total`, `total`, `amount_due`) and the payments made at checkout, so one order summary component can render either.++### Store credit no longer includes gift cards++A gift card is redeemed as store credit. `store_credit_total` used to include that amount as well as `gift_card_total`, so a summary showing both rows took it off twice. It now holds only the store credit that is not from a gift card. A storefront that shows one row or the other keeps working, and one that shows both no longer deducts the gift card twice.+### Request types match the APIRequest types (`CreateCartParams`, `UpdateCartParams`, `AddLineItemParams`, `AddressParams` and the rest) are generated from what each endpoint accepts. Fields the API never accepted are gone, so a type error there means the value was being dropped. Fields the API accepted but the old types left out are now available.@@ -1186,6 +1196,9 @@ These Store API fields keep working in 6.0 and are marked `@deprecated` in the S|---|---|| Address `country_iso`, read and written | `country_code` || Address `state_abbr`, read and written | `state_code` |+| Stock location `country_iso` | `country_code` |+| Stock location `state_abbr` | `state_code` |+| Refund `reimbursement_id` (always `null`: reimbursements are folded into returns) | `originator_id` with `originator_type` || Company address `zipcode`, written | `postal_code` || Cart `number` | `id` || Market `country_isos` | `country_codes` |diff --git a/packages/admin-sdk/src/types/generated/Cart.ts b/packages/admin-sdk/src/types/generated/Cart.tsindex d9c4a3e70b..d14e2e3baf 100644--- a/packages/admin-sdk/src/types/generated/Cart.ts+++ b/packages/admin-sdk/src/types/generated/Cart.ts@@ -1,4 +1,4 @@-// Typelizer digest f738f60ecfdf9e1b139bcb39e1c0867c+// Typelizer digest f2ee3f8658c4b99835c5e58bcf4a3ae0//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {FreightSummary, LineItem, Address, Market, AppliedPromotion, CurrencyCode} from '@/types'@@ -23,18 +23,18 @@ interface Cart {warnings: Array<{code: string, message: string, line_item_id?: string, variant_id?: string, item_index?: number}>;coupon_code: string | null;item_total: string | null;- adjustment_total: string | null;discount_total: string | null;tax_total: string | null;included_tax_total: string | null;additional_tax_total: string | null;- total: string | null;- gift_card_total: string | null;- amount_due: string | null;delivery_total: string | null;fee_total: string | null;+ gift_card_total: string | null;store_credit_total: string | null;+ total: string | null;+ amount_due: string | null;covered_by_store_credit: boolean;+ adjustment_total: string | null;current_step: string;completed_steps: Array<string>;requirements: Array<{step: string, field: string, code: string, message: string}>;diff --git a/packages/admin-sdk/src/types/generated/Order.ts b/packages/admin-sdk/src/types/generated/Order.tsindex bcba733682..512047517b 100644--- a/packages/admin-sdk/src/types/generated/Order.ts+++ b/packages/admin-sdk/src/types/generated/Order.ts@@ -1,7 +1,7 @@-// Typelizer digest 4c90e1db894d2005fe7f3731fe39ad0c+// Typelizer digest a832c07d5def234561478a7a2f1880aa//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {FreightSummary, LineItem, Fulfillment, Payment, Address, GiftCard, Market, Seller, Actor, AppliedPromotion, PaymentSplit, Cart, Channel, StockLocation, PaymentMethod, Customer, OrderCancellationReason, Return, Exchange, Claim, CurrencyCode, ActorKind} from '@/types'+import type {FreightSummary, Payment, LineItem, Fulfillment, Address, GiftCard, Market, Seller, Actor, AppliedPromotion, PaymentSplit, Cart, Channel, StockLocation, PaymentMethod, Customer, OrderCancellationReason, Return, Exchange, Claim, CurrencyCode, ActorKind} from '@/types'interface Order {id: string;@@ -26,21 +26,21 @@ interface Order {payment_status: 'none' | 'authorized' | 'partially_paid' | 'paid' | 'partially_refunded' | 'refunded' | 'overcharged' | 'voided' | null;completed_at: string | null;item_total: string;- adjustment_total: string;discount_total: string;tax_total: string;included_tax_total: string;additional_tax_total: string;- total: string;- gift_card_total: string;- amount_due: string;delivery_total: string;fee_total: string;+ gift_card_total: string;store_credit_total: string;+ total: string;+ amount_due: string;covered_by_store_credit: boolean;+ payments?: Array<Payment>;+ adjustment_total: string;items?: Array<LineItem>;fulfillments?: Array<Fulfillment>;- payments?: Array<Payment>;billing_address?: Address | null;shipping_address?: Address | null;gift_card: GiftCard | null;diff --git a/packages/admin-sdk/src/types/generated/OrderGroup.ts b/packages/admin-sdk/src/types/generated/OrderGroup.tsindex ba9eb282aa..665348e044 100644--- a/packages/admin-sdk/src/types/generated/OrderGroup.ts+++ b/packages/admin-sdk/src/types/generated/OrderGroup.ts@@ -1,15 +1,26 @@-// Typelizer digest ec6a0033a30f99bb20eac2ebeb6daa79+// Typelizer digest 3414cbff12fc8b677003fddff72727a5//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {Address, Order, Payment, CurrencyCode} from '@/types'+import type {Payment, Address, Order, CurrencyCode} from '@/types'interface OrderGroup {id: string;number: string;email: string | null;currency: CurrencyCode;- total: string | null;item_total: string | null;+ discount_total: string | null;+ tax_total: string | null;+ included_tax_total: string | null;+ additional_tax_total: string | null;+ delivery_total: string | null;+ fee_total: string | null;+ gift_card_total: string | null;+ store_credit_total: string | null;+ total: string | null;+ amount_due: string | null;+ covered_by_store_credit: boolean;+ payments: Array<Payment>;fulfillment_status: 'backorder' | 'canceled' | 'partial' | 'unfulfilled' | 'fulfilled' | 'delivered' | 'pending' | 'ready' | 'shipped' | null;payment_status: 'none' | 'authorized' | 'partially_paid' | 'paid' | 'partially_refunded' | 'refunded' | 'overcharged' | 'voided' | null;completed_at: string | null;@@ -24,7 +35,6 @@ interface OrderGroup {store_owner_notification_delivered: boolean;created_at: string;updated_at: string;- payments: Array<Payment>;}export default OrderGroup;diff --git a/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts b/packages/admin-sdk/src/types/generated/emails/EmailOrder.tsindex 7ff03f1ae3..430e346486 100644--- a/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts+++ b/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts@@ -1,7 +1,7 @@-// Typelizer digest 2703884d9195a46457f23d1fecd0334d+// Typelizer digest a2f82c5fe2aeae6f78bacaeee8be666f//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {EmailAppliedPromotion, EmailFee, EmailLineItem, EmailFulfillment, EmailPayment, EmailAddress, EmailGiftCard, EmailMarket, EmailAmountLine, CurrencyCode} from '.'+import type {EmailPayment, EmailAppliedPromotion, EmailFee, EmailLineItem, EmailFulfillment, EmailAddress, EmailGiftCard, EmailMarket, EmailAmountLine, CurrencyCode} from '.'interface EmailOrder {id: string;@@ -27,8 +27,6 @@ interface EmailOrder {completed_at: string | null;item_total: string | null;display_item_total: string | null;- adjustment_total: string | null;- display_adjustment_total: string | null;discount_total: string | null;display_discount_total: string | null;tax_total: string | null;@@ -37,24 +35,26 @@ interface EmailOrder {display_included_tax_total: string | null;additional_tax_total: string | null;display_additional_tax_total: string | null;- total: string | null;- display_total: string | null;- gift_card_total: string | null;- display_gift_card_total: string | null;- amount_due: string | null;- display_amount_due: string | null;delivery_total: string | null;display_delivery_total: string | null;fee_total: string | null;display_fee_total: string | null;+ gift_card_total: string | null;+ display_gift_card_total: string | null;store_credit_total: string | null;display_store_credit_total: string | null;+ total: string | null;+ display_total: string | null;+ amount_due: string | null;+ display_amount_due: string | null;covered_by_store_credit: boolean;+ payments: Array<EmailPayment>;+ adjustment_total: string | null;+ display_adjustment_total: string | null;discounts: Array<EmailAppliedPromotion>;fees: Array<EmailFee>;items: Array<EmailLineItem>;fulfillments: Array<EmailFulfillment>;- payments: Array<EmailPayment>;billing_address: EmailAddress | null;shipping_address: EmailAddress | null;gift_card: EmailGiftCard | null;diff --git a/packages/admin-sdk/src/types/generated/emails/EmailOrderGroup.ts b/packages/admin-sdk/src/types/generated/emails/EmailOrderGroup.tsindex c19ea150bc..491b1c29ee 100644--- a/packages/admin-sdk/src/types/generated/emails/EmailOrderGroup.ts+++ b/packages/admin-sdk/src/types/generated/emails/EmailOrderGroup.ts@@ -1,17 +1,37 @@-// Typelizer digest ef1236ef103cf5062d09ba432a0f4696+// Typelizer digest 993251fbcbb39ee47da3259734bb4c7d//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {EmailAddress, EmailLineItem, EmailAmountLine, EmailFulfillmentGroup, CurrencyCode} from '.'+import type {EmailPayment, EmailAddress, EmailLineItem, EmailAmountLine, EmailFulfillmentGroup, CurrencyCode} from '.'interface EmailOrderGroup {id: string;number: string;email: string | null;currency: CurrencyCode;- total: string | null;- display_total: string | null;item_total: string | null;display_item_total: string | null;+ discount_total: string | null;+ display_discount_total: string | null;+ tax_total: string | null;+ display_tax_total: string | null;+ included_tax_total: string | null;+ display_included_tax_total: string | null;+ additional_tax_total: string | null;+ display_additional_tax_total: string | null;+ delivery_total: string | null;+ display_delivery_total: string | null;+ fee_total: string | null;+ display_fee_total: string | null;+ gift_card_total: string | null;+ display_gift_card_total: string | null;+ store_credit_total: string | null;+ display_store_credit_total: string | null;+ total: string | null;+ display_total: string | null;+ amount_due: string | null;+ display_amount_due: string | null;+ covered_by_store_credit: boolean;+ payments: Array<EmailPayment>;fulfillment_status: 'backorder' | 'canceled' | 'partial' | 'unfulfilled' | 'fulfilled' | 'delivered' | 'pending' | 'ready' | 'shipped' | null;payment_status: 'none' | 'authorized' | 'partially_paid' | 'paid' | 'partially_refunded' | 'refunded' | 'overcharged' | 'voided' | null;completed_at: string | null;@@ -26,12 +46,6 @@ interface EmailOrderGroup {fee_lines: Array<EmailAmountLine>;po_number: string | null;order_count: number;- display_delivery_total: string;- delivery_total: string;- additional_tax_total: string;- display_additional_tax_total: string;- gift_card_total: string;- display_gift_card_total: string;fulfillment_groups: Array<EmailFulfillmentGroup>;unfulfilled_items: Array<EmailLineItem>;delivery_lines: Array<EmailAmountLine>;diff --git a/packages/admin-sdk/src/types/generated/emails/EmailStockLocation.ts b/packages/admin-sdk/src/types/generated/emails/EmailStockLocation.tsindex 7869998be0..95fb9967b9 100644--- a/packages/admin-sdk/src/types/generated/emails/EmailStockLocation.ts+++ b/packages/admin-sdk/src/types/generated/emails/EmailStockLocation.ts@@ -1,4 +1,4 @@-// Typelizer digest da0e5e1f06910a878a7ba45e4d52ea27+// Typelizer digest 78df99bb7bb1f4b7a37cfeb03c0c41f6//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {CountryCode} from '.'@@ -13,6 +13,10 @@ interface EmailStockLocation {country_name: string | null;state_code: string | null;state_text: string | null;+ /** @deprecated Use `country_code`. Removed in 6.1. */+ country_iso: string | null;+ /** @deprecated Use `state_code`. Removed in 6.1. */+ state_abbr: string | null;pickup_ready_in_minutes: number | null;pickup_instructions: string | null;}diff --git a/packages/admin-sdk/src/zod/generated/Cart.ts b/packages/admin-sdk/src/zod/generated/Cart.tsindex a37eb50865..b7896237f4 100644--- a/packages/admin-sdk/src/zod/generated/Cart.ts+++ b/packages/admin-sdk/src/zod/generated/Cart.ts@@ -26,18 +26,18 @@ export const CartSchema = z.object({warnings: z.array(z.object({ code: z.string(), message: z.string(), line_item_id: z.string().optional(), variant_id: z.string().optional(), item_index: z.number().optional() })),coupon_code: z.string().nullable(),item_total: z.string().nullable(),- adjustment_total: z.string().nullable(),discount_total: z.string().nullable(),tax_total: z.string().nullable(),included_tax_total: z.string().nullable(),additional_tax_total: z.string().nullable(),- total: z.string().nullable(),- gift_card_total: z.string().nullable(),- amount_due: z.string().nullable(),delivery_total: z.string().nullable(),fee_total: z.string().nullable(),+ gift_card_total: z.string().nullable(),store_credit_total: z.string().nullable(),+ total: z.string().nullable(),+ amount_due: z.string().nullable(),covered_by_store_credit: z.boolean(),+ adjustment_total: z.string().nullable(),current_step: z.string(),completed_steps: z.array(z.string()),requirements: z.array(z.object({ step: z.string(), field: z.string(), code: z.string(), message: z.string() })),diff --git a/packages/admin-sdk/src/zod/generated/Order.ts b/packages/admin-sdk/src/zod/generated/Order.tsindex 921117e121..1cc0e87878 100644--- a/packages/admin-sdk/src/zod/generated/Order.ts+++ b/packages/admin-sdk/src/zod/generated/Order.ts@@ -44,21 +44,21 @@ export const OrderSchema = z.object({payment_status: z.string().nullable(),completed_at: z.string().nullable(),item_total: z.string(),- adjustment_total: z.string(),discount_total: z.string(),tax_total: z.string(),included_tax_total: z.string(),additional_tax_total: z.string(),- total: z.string(),- gift_card_total: z.string(),- amount_due: z.string(),delivery_total: z.string(),fee_total: z.string(),+ gift_card_total: z.string(),store_credit_total: z.string(),+ total: z.string(),+ amount_due: z.string(),covered_by_store_credit: z.boolean(),+ get payments() { return z.array(PaymentSchema).optional(); },+ adjustment_total: z.string(),items: z.array(LineItemSchema).optional(),get fulfillments() { return z.array(FulfillmentSchema).optional(); },- get payments() { return z.array(PaymentSchema).optional(); },billing_address: AddressSchema.nullable().optional(),shipping_address: AddressSchema.nullable().optional(),get gift_card() { return GiftCardSchema.nullable(); },diff --git a/packages/admin-sdk/src/zod/generated/OrderGroup.ts b/packages/admin-sdk/src/zod/generated/OrderGroup.tsindex b7f3cd94aa..c7399a0bdd 100644--- a/packages/admin-sdk/src/zod/generated/OrderGroup.ts+++ b/packages/admin-sdk/src/zod/generated/OrderGroup.ts@@ -9,8 +9,19 @@ export const OrderGroupSchema = z.object({number: z.string(),email: z.string().nullable(),currency: z.string(),- total: z.string().nullable(),item_total: z.string().nullable(),+ discount_total: z.string().nullable(),+ tax_total: z.string().nullable(),+ included_tax_total: z.string().nullable(),+ additional_tax_total: z.string().nullable(),+ delivery_total: z.string().nullable(),+ fee_total: z.string().nullable(),+ gift_card_total: z.string().nullable(),+ store_credit_total: z.string().nullable(),+ total: z.string().nullable(),+ amount_due: z.string().nullable(),+ covered_by_store_credit: z.boolean(),+ get payments() { return z.array(PaymentSchema); },fulfillment_status: z.string().nullable(),payment_status: z.string().nullable(),completed_at: z.string().nullable(),@@ -25,7 +36,6 @@ export const OrderGroupSchema = z.object({store_owner_notification_delivered: z.boolean(),created_at: z.string(),updated_at: z.string(),- get payments() { return z.array(PaymentSchema); },});export type OrderGroup = z.infer<typeof OrderGroupSchema>;diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailOrder.ts b/packages/admin-sdk/src/zod/generated/emails/EmailOrder.tsindex 78ee79b24a..adfe40fead 100644--- a/packages/admin-sdk/src/zod/generated/emails/EmailOrder.ts+++ b/packages/admin-sdk/src/zod/generated/emails/EmailOrder.ts@@ -34,8 +34,6 @@ export const EmailOrderSchema = z.object({completed_at: z.string().nullable(),item_total: z.string().nullable(),display_item_total: z.string().nullable(),- adjustment_total: z.string().nullable(),- display_adjustment_total: z.string().nullable(),discount_total: z.string().nullable(),display_discount_total: z.string().nullable(),tax_total: z.string().nullable(),@@ -44,24 +42,26 @@ export const EmailOrderSchema = z.object({display_included_tax_total: z.string().nullable(),additional_tax_total: z.string().nullable(),display_additional_tax_total: z.string().nullable(),- total: z.string().nullable(),- display_total: z.string().nullable(),- gift_card_total: z.string().nullable(),- display_gift_card_total: z.string().nullable(),- amount_due: z.string().nullable(),- display_amount_due: z.string().nullable(),delivery_total: z.string().nullable(),display_delivery_total: z.string().nullable(),fee_total: z.string().nullable(),display_fee_total: z.string().nullable(),+ gift_card_total: z.string().nullable(),+ display_gift_card_total: z.string().nullable(),store_credit_total: z.string().nullable(),display_store_credit_total: z.string().nullable(),+ total: z.string().nullable(),+ display_total: z.string().nullable(),+ amount_due: z.string().nullable(),+ display_amount_due: z.string().nullable(),covered_by_store_credit: z.boolean(),+ payments: z.array(EmailPaymentSchema),+ adjustment_total: z.string().nullable(),+ display_adjustment_total: z.string().nullable(),discounts: z.array(EmailAppliedPromotionSchema),fees: z.array(EmailFeeSchema),items: z.array(EmailLineItemSchema),fulfillments: z.array(EmailFulfillmentSchema),- payments: z.array(EmailPaymentSchema),billing_address: EmailAddressSchema.nullable(),shipping_address: EmailAddressSchema.nullable(),gift_card: EmailGiftCardSchema.nullable(),diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailOrderGroup.ts b/packages/admin-sdk/src/zod/generated/emails/EmailOrderGroup.tsindex e84253cb42..59b4d81ac7 100644--- a/packages/admin-sdk/src/zod/generated/emails/EmailOrderGroup.ts+++ b/packages/admin-sdk/src/zod/generated/emails/EmailOrderGroup.ts@@ -4,16 +4,37 @@ import { EmailAddressSchema } from './EmailAddress';import { EmailAmountLineSchema } from './EmailAmountLine';import { EmailFulfillmentGroupSchema } from './EmailFulfillmentGroup';import { EmailLineItemSchema } from './EmailLineItem';+import { EmailPaymentSchema } from './EmailPayment';export const EmailOrderGroupSchema = z.object({id: z.string(),number: z.string(),email: z.string().nullable(),currency: z.string(),- total: z.string().nullable(),- display_total: z.string().nullable(),item_total: z.string().nullable(),display_item_total: z.string().nullable(),+ discount_total: z.string().nullable(),+ display_discount_total: z.string().nullable(),+ tax_total: z.string().nullable(),+ display_tax_total: z.string().nullable(),+ included_tax_total: z.string().nullable(),+ display_included_tax_total: z.string().nullable(),+ additional_tax_total: z.string().nullable(),+ display_additional_tax_total: z.string().nullable(),+ delivery_total: z.string().nullable(),+ display_delivery_total: z.string().nullable(),+ fee_total: z.string().nullable(),+ display_fee_total: z.string().nullable(),+ gift_card_total: z.string().nullable(),+ display_gift_card_total: z.string().nullable(),+ store_credit_total: z.string().nullable(),+ display_store_credit_total: z.string().nullable(),+ total: z.string().nullable(),+ display_total: z.string().nullable(),+ amount_due: z.string().nullable(),+ display_amount_due: z.string().nullable(),+ covered_by_store_credit: z.boolean(),+ payments: z.array(EmailPaymentSchema),fulfillment_status: z.string().nullable(),payment_status: z.string().nullable(),completed_at: z.string().nullable(),@@ -28,12 +49,6 @@ export const EmailOrderGroupSchema = z.object({fee_lines: z.array(EmailAmountLineSchema),po_number: z.string().nullable(),order_count: z.number(),- display_delivery_total: z.string(),- delivery_total: z.string(),- additional_tax_total: z.string(),- display_additional_tax_total: z.string(),- gift_card_total: z.string(),- display_gift_card_total: z.string(),fulfillment_groups: z.array(EmailFulfillmentGroupSchema),unfulfilled_items: z.array(EmailLineItemSchema),delivery_lines: z.array(EmailAmountLineSchema),diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailStockLocation.ts b/packages/admin-sdk/src/zod/generated/emails/EmailStockLocation.tsindex 27c3644a6f..14ec0b9c29 100644--- a/packages/admin-sdk/src/zod/generated/emails/EmailStockLocation.ts+++ b/packages/admin-sdk/src/zod/generated/emails/EmailStockLocation.ts@@ -11,6 +11,8 @@ export const EmailStockLocationSchema = z.object({country_name: z.string().nullable(),state_code: z.string().nullable(),state_text: z.string().nullable(),+ country_iso: z.string().nullable(),+ state_abbr: z.string().nullable(),pickup_ready_in_minutes: z.number().nullable(),pickup_instructions: z.string().nullable(),});diff --git a/packages/dashboard/src/lib/email-template-variables.ts b/packages/dashboard/src/lib/email-template-variables.tsindex eb1711154a..a6e9a0d68d 100644--- a/packages/dashboard/src/lib/email-template-variables.ts+++ b/packages/dashboard/src/lib/email-template-variables.ts@@ -100,13 +100,21 @@ export const EMAIL_TEMPLATE_VARIABLES: Record<string, EmailTemplateVariable[]> =['number','customer_name',+ 'email',+ 'completed_at','order_count','items','fulfillment_groups',+ 'item_total',+ 'delivery_total',+ 'tax_total','total',+ 'shipping_address',+ 'billing_address',+ 'payments',] as const satisfies FieldsOf<EmailOrderGroup>,EmailOrderGroupSchema,- ['total'] satisfies FieldsOf<EmailOrderGroup>,+ ['item_total', 'delivery_total', 'tax_total', 'total'] satisfies FieldsOf<EmailOrderGroup>,),resend,],diff --git a/packages/sdk/src/store-client.ts b/packages/sdk/src/store-client.tsindex a53e7771cd..765a532303 100644--- a/packages/sdk/src/store-client.ts+++ b/packages/sdk/src/store-client.ts@@ -785,13 +785,19 @@ export class StoreClient {/*** Get a completed order by prefixed ID.* Accessible via JWT (authenticated users) or spreeToken (guests).+ *+ * Also accepts the id of the cart the checkout was placed from — the+ * handle a storefront still holds on its confirmation page. A checkout+ * that reached several sellers resolves there to the group of orders it+ * produced rather than to any one of them, exactly as `carts.complete`+ * answered it; narrow the result with `isOrderGroup`.*/get: (id: string,params?: { expand?: string[]; fields?: string[] },options?: RequestOptions,- ): Promise<Order> =>- this.request<Order>('GET', `/orders/${id}`, {+ ): Promise<Order | OrderGroup> =>+ this.request<Order | OrderGroup>('GET', `/orders/${id}`, {...options,params: getParams(params),}),diff --git a/packages/sdk/src/types/generated/Cart.ts b/packages/sdk/src/types/generated/Cart.tsindex bc0b644449..757c710b40 100644--- a/packages/sdk/src/types/generated/Cart.ts+++ b/packages/sdk/src/types/generated/Cart.ts@@ -1,7 +1,7 @@-// Typelizer digest 6a558481eadbd2f3d1569efb61bdae03+// Typelizer digest 622e59e73af914c7672ec39b7cd24481//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {FreightSummary, AppliedPromotion, Fee, LineItem, Fulfillment, Payment, Address, PaymentMethod, GiftCard, Market, CurrencyCode} from '@/types'+import type {FreightSummary, Payment, AppliedPromotion, Fee, LineItem, Fulfillment, Address, PaymentMethod, GiftCard, Market, CurrencyCode} from '@/types'interface Cart {id: string;@@ -26,8 +26,6 @@ interface Cart {coupon_code: string | null;item_total: string | null;display_item_total: string | null;- adjustment_total: string | null;- display_adjustment_total: string | null;discount_total: string | null;display_discount_total: string | null;tax_total: string | null;@@ -36,19 +34,22 @@ interface Cart {display_included_tax_total: string | null;additional_tax_total: string | null;display_additional_tax_total: string | null;- total: string | null;- display_total: string | null;- gift_card_total: string | null;- display_gift_card_total: string | null;- amount_due: string | null;- display_amount_due: string | null;delivery_total: string | null;display_delivery_total: string | null;fee_total: string | null;display_fee_total: string | null;+ gift_card_total: string | null;+ display_gift_card_total: string | null;store_credit_total: string | null;display_store_credit_total: string | null;+ total: string | null;+ display_total: string | null;+ amount_due: string | null;+ display_amount_due: string | null;covered_by_store_credit: boolean;+ payments: Array<Payment>;+ adjustment_total: string | null;+ display_adjustment_total: string | null;current_step: string;completed_steps: Array<string>;requirements: Array<{step: string, field: string, code: string, message: string}>;@@ -61,7 +62,6 @@ interface Cart {fees: Array<Fee>;items: Array<LineItem>;fulfillments: Array<Fulfillment>;- payments: Array<Payment>;billing_address: Address | null;shipping_address: Address | null;payment_methods: Array<PaymentMethod>;diff --git a/packages/sdk/src/types/generated/Order.ts b/packages/sdk/src/types/generated/Order.tsindex 41b71deccb..4113fcc7d4 100644--- a/packages/sdk/src/types/generated/Order.ts+++ b/packages/sdk/src/types/generated/Order.ts@@ -1,7 +1,7 @@-// Typelizer digest 4d39933f6969ae65f4bf9248169d0f54+// Typelizer digest 3591f6fa021bb07bfff31c9b20dc9bdf//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {AppliedPromotion, Fee, LineItem, Fulfillment, Payment, Address, GiftCard, Market, CurrencyCode} from '@/types'+import type {Payment, AppliedPromotion, Fee, LineItem, Fulfillment, Address, GiftCard, Market, CurrencyCode} from '@/types'interface Order {id: string;@@ -27,8 +27,6 @@ interface Order {completed_at: string | null;item_total: string | null;display_item_total: string | null;- adjustment_total: string | null;- display_adjustment_total: string | null;discount_total: string | null;display_discount_total: string | null;tax_total: string | null;@@ -37,24 +35,26 @@ interface Order {display_included_tax_total: string | null;additional_tax_total: string | null;display_additional_tax_total: string | null;- total: string | null;- display_total: string | null;- gift_card_total: string | null;- display_gift_card_total: string | null;- amount_due: string | null;- display_amount_due: string | null;delivery_total: string | null;display_delivery_total: string | null;fee_total: string | null;display_fee_total: string | null;+ gift_card_total: string | null;+ display_gift_card_total: string | null;store_credit_total: string | null;display_store_credit_total: string | null;+ total: string | null;+ display_total: string | null;+ amount_due: string | null;+ display_amount_due: string | null;covered_by_store_credit: boolean;+ payments: Array<Payment>;+ adjustment_total: string | null;+ display_adjustment_total: string | null;discounts: Array<AppliedPromotion>;fees: Array<Fee>;items: Array<LineItem>;fulfillments: Array<Fulfillment>;- payments: Array<Payment>;billing_address: Address | null;shipping_address: Address | null;gift_card: GiftCard | null;diff --git a/packages/sdk/src/types/generated/OrderGroup.ts b/packages/sdk/src/types/generated/OrderGroup.tsindex 8090946671..11001b2ac5 100644--- a/packages/sdk/src/types/generated/OrderGroup.ts+++ b/packages/sdk/src/types/generated/OrderGroup.ts@@ -1,17 +1,37 @@-// Typelizer digest 4652f4e56c7e1ce5a74c3604e7500a67+// Typelizer digest 832e29db012712d0637162ae388b9a89//// DO NOT MODIFY: This file was automatically generated by Typelizer.-import type {Address, Order, CurrencyCode} from '@/types'+import type {Payment, Address, Order, CurrencyCode} from '@/types'interface OrderGroup {id: string;number: string;email: string | null;currency: CurrencyCode;- total: string | null;- display_total: string | null;item_total: string | null;display_item_total: string | null;+ discount_total: string | null;+ display_discount_total: string | null;+ tax_total: string | null;+ display_tax_total: string | null;+ included_tax_total: string | null;+ display_included_tax_total: string | null;+ additional_tax_total: string | null;+ display_additional_tax_total: string | null;+ delivery_total: string | null;+ display_delivery_total: string | null;+ fee_total: string | null;+ display_fee_total: string | null;+ gift_card_total: string | null;+ display_gift_card_total: string | null;+ store_credit_total: string | null;+ display_store_credit_total: string | null;+ total: string | null;+ display_total: string | null;+ amount_due: string | null;+ display_amount_due: string | null;+ covered_by_store_credit: boolean;+ payments: Array<Payment>;fulfillment_status: 'backorder' | 'canceled' | 'partial' | 'unfulfilled' | 'fulfilled' | 'delivered' | 'pending' | 'ready' | 'shipped' | null;payment_status: 'none' | 'authorized' | 'partially_paid' | 'paid' | 'partially_refunded' | 'refunded' | 'overcharged' | 'voided' | null;completed_at: string | null;diff --git a/packages/sdk/src/types/generated/Refund.ts b/packages/sdk/src/types/generated/Refund.tsindex 7d484ff943..25addc851a 100644--- a/packages/sdk/src/types/generated/Refund.ts+++ b/packages/sdk/src/types/generated/Refund.ts@@ -1,4 +1,4 @@-// Typelizer digest ecfd3951bcab7a3af1649f7e4964be25+// Typelizer digest be8a96dc13f13589cb29397dfad9f45a//// DO NOT MODIFY: This file was automatically generated by Typelizer.@@ -10,6 +10,8 @@ interface Refund {refund_reason_id: string | null;originator_id: string | null;originator_type: string | null;+ /** @deprecated Always null: reimbursements are gone. Use `originator_id`. Removed in 6.1. */+ reimbursement_id: string | null;}export default Refund;diff --git a/packages/sdk/src/types/generated/StockLocation.ts b/packages/sdk/src/types/generated/StockLocation.tsindex 31e694aec1..b62188b8ea 100644--- a/packages/sdk/src/types/generated/StockLocation.ts+++ b/packages/sdk/src/types/generated/StockLocation.ts@@ -1,4 +1,4 @@-// Typelizer digest 4b297977629c3ebddfeaa9ce7bf11757+// Typelizer digest 7a2442564ddb8458e77cbbeea2ddcb74//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {CountryCode} from '@/types'@@ -13,6 +13,10 @@ interface StockLocation {country_name: string | null;state_code: string | null;state_text: string | null;+ /** @deprecated Use `country_code`. Removed in 6.1. */+ country_iso: string | null;+ /** @deprecated Use `state_code`. Removed in 6.1. */+ state_abbr: string | null;pickup_ready_in_minutes: number | null;pickup_instructions: string | null;}diff --git a/packages/sdk/src/types/index.ts b/packages/sdk/src/types/index.tsindex 7a59552154..c3e500b49b 100644--- a/packages/sdk/src/types/index.ts+++ b/packages/sdk/src/types/index.ts@@ -16,6 +16,7 @@ export * from './filters.generated'// Re-export all generated types (unprefixed: Product, Order, etc.)export type {Address,+ AppliedPromotion,Base,Cart,Category,@@ -32,11 +33,13 @@ export type {Customer,CustomerGroup,CustomField,+ Delivery,DeliveryMethod,DeliveryRate,DigitalAsset,DigitalLink,Discount,+ Fee,FreightSummary,Fulfillment,GiftCard,@@ -67,6 +70,7 @@ export type {State,StockLocation,StoreCredit,+ TaxLine,Variant,Wishlist,WishlistItem,diff --git a/packages/sdk/src/zod/generated/Cart.ts b/packages/sdk/src/zod/generated/Cart.tsindex 362d5f0bb4..0a866d4e46 100644--- a/packages/sdk/src/zod/generated/Cart.ts+++ b/packages/sdk/src/zod/generated/Cart.ts@@ -33,8 +33,6 @@ export const CartSchema = z.object({coupon_code: z.string().nullable(),item_total: z.string().nullable(),display_item_total: z.string().nullable(),- adjustment_total: z.string().nullable(),- display_adjustment_total: z.string().nullable(),discount_total: z.string().nullable(),display_discount_total: z.string().nullable(),tax_total: z.string().nullable(),@@ -43,19 +41,22 @@ export const CartSchema = z.object({display_included_tax_total: z.string().nullable(),additional_tax_total: z.string().nullable(),display_additional_tax_total: z.string().nullable(),- total: z.string().nullable(),- display_total: z.string().nullable(),- gift_card_total: z.string().nullable(),- display_gift_card_total: z.string().nullable(),- amount_due: z.string().nullable(),- display_amount_due: z.string().nullable(),delivery_total: z.string().nullable(),display_delivery_total: z.string().nullable(),fee_total: z.string().nullable(),display_fee_total: z.string().nullable(),+ gift_card_total: z.string().nullable(),+ display_gift_card_total: z.string().nullable(),store_credit_total: z.string().nullable(),display_store_credit_total: z.string().nullable(),+ total: z.string().nullable(),+ display_total: z.string().nullable(),+ amount_due: z.string().nullable(),+ display_amount_due: z.string().nullable(),covered_by_store_credit: z.boolean(),+ payments: z.array(PaymentSchema),+ adjustment_total: z.string().nullable(),+ display_adjustment_total: z.string().nullable(),current_step: z.string(),completed_steps: z.array(z.string()),requirements: z.array(z.object({ step: z.string(), field: z.string(), code: z.string(), message: z.string() })),@@ -68,7 +69,6 @@ export const CartSchema = z.object({fees: z.array(FeeSchema),items: z.array(LineItemSchema),fulfillments: z.array(FulfillmentSchema),- payments: z.array(PaymentSchema),billing_address: AddressSchema.nullable(),shipping_address: AddressSchema.nullable(),payment_methods: z.array(PaymentMethodSchema),diff --git a/packages/sdk/src/zod/generated/Order.ts b/packages/sdk/src/zod/generated/Order.tsindex 2151efd11a..29ccab3881 100644--- a/packages/sdk/src/zod/generated/Order.ts+++ b/packages/sdk/src/zod/generated/Order.ts@@ -33,8 +33,6 @@ export const OrderSchema = z.object({completed_at: z.string().nullable(),item_total: z.string().nullable(),display_item_total: z.string().nullable(),- adjustment_total: z.string().nullable(),- display_adjustment_total: z.string().nullable(),discount_total: z.string().nullable(),display_discount_total: z.string().nullable(),tax_total: z.string().nullable(),@@ -43,24 +41,26 @@ export const OrderSchema = z.object({display_included_tax_total: z.string().nullable(),additional_tax_total: z.string().nullable(),display_additional_tax_total: z.string().nullable(),- total: z.string().nullable(),- display_total: z.string().nullable(),- gift_card_total: z.string().nullable(),- display_gift_card_total: z.string().nullable(),- amount_due: z.string().nullable(),- display_amount_due: z.string().nullable(),delivery_total: z.string().nullable(),display_delivery_total: z.string().nullable(),fee_total: z.string().nullable(),display_fee_total: z.string().nullable(),+ gift_card_total: z.string().nullable(),+ display_gift_card_total: z.string().nullable(),store_credit_total: z.string().nullable(),display_store_credit_total: z.string().nullable(),+ total: z.string().nullable(),+ display_total: z.string().nullable(),+ amount_due: z.string().nullable(),+ display_amount_due: z.string().nullable(),covered_by_store_credit: z.boolean(),+ payments: z.array(PaymentSchema),+ adjustment_total: z.string().nullable(),+ display_adjustment_total: z.string().nullable(),discounts: z.array(AppliedPromotionSchema),fees: z.array(FeeSchema),items: z.array(LineItemSchema),fulfillments: z.array(FulfillmentSchema),- payments: z.array(PaymentSchema),billing_address: AddressSchema.nullable(),shipping_address: AddressSchema.nullable(),gift_card: GiftCardSchema.nullable(),diff --git a/packages/sdk/src/zod/generated/OrderGroup.ts b/packages/sdk/src/zod/generated/OrderGroup.tsindex 1d551db9d7..2a3a67dc2f 100644--- a/packages/sdk/src/zod/generated/OrderGroup.ts+++ b/packages/sdk/src/zod/generated/OrderGroup.ts@@ -2,16 +2,37 @@import { z } from 'zod';import { AddressSchema } from './Address';import { OrderSchema } from './Order';+import { PaymentSchema } from './Payment';export const OrderGroupSchema = z.object({id: z.string(),number: z.string(),email: z.string().nullable(),currency: z.string(),- total: z.string().nullable(),- display_total: z.string().nullable(),item_total: z.string().nullable(),display_item_total: z.string().nullable(),+ discount_total: z.string().nullable(),+ display_discount_total: z.string().nullable(),+ tax_total: z.string().nullable(),+ display_tax_total: z.string().nullable(),+ included_tax_total: z.string().nullable(),+ display_included_tax_total: z.string().nullable(),+ additional_tax_total: z.string().nullable(),+ display_additional_tax_total: z.string().nullable(),+ delivery_total: z.string().nullable(),+ display_delivery_total: z.string().nullable(),+ fee_total: z.string().nullable(),+ display_fee_total: z.string().nullable(),+ gift_card_total: z.string().nullable(),+ display_gift_card_total: z.string().nullable(),+ store_credit_total: z.string().nullable(),+ display_store_credit_total: z.string().nullable(),+ total: z.string().nullable(),+ display_total: z.string().nullable(),+ amount_due: z.string().nullable(),+ display_amount_due: z.string().nullable(),+ covered_by_store_credit: z.boolean(),+ payments: z.array(PaymentSchema),fulfillment_status: z.string().nullable(),payment_status: z.string().nullable(),completed_at: z.string().nullable(),diff --git a/packages/sdk/src/zod/generated/Refund.ts b/packages/sdk/src/zod/generated/Refund.tsindex 155ca929ca..7f49fea1d8 100644--- a/packages/sdk/src/zod/generated/Refund.ts+++ b/packages/sdk/src/zod/generated/Refund.ts@@ -9,6 +9,7 @@ export const RefundSchema = z.object({refund_reason_id: z.string().nullable(),originator_id: z.string().nullable(),originator_type: z.string().nullable(),+ reimbursement_id: z.string().nullable(),});export type Refund = z.infer<typeof RefundSchema>;diff --git a/packages/sdk/src/zod/generated/StockLocation.ts b/packages/sdk/src/zod/generated/StockLocation.tsindex 219f44d218..e83c6c3719 100644--- a/packages/sdk/src/zod/generated/StockLocation.ts+++ b/packages/sdk/src/zod/generated/StockLocation.ts@@ -11,6 +11,8 @@ export const StockLocationSchema = z.object({country_name: z.string().nullable(),state_code: z.string().nullable(),state_text: z.string().nullable(),+ country_iso: z.string().nullable(),+ state_abbr: z.string().nullable(),pickup_ready_in_minutes: z.number().nullable(),pickup_instructions: z.string().nullable(),});diff --git a/spree/api/app/controllers/concerns/spree/api/v3/cart_resolvable.rb b/spree/api/app/controllers/concerns/spree/api/v3/cart_resolvable.rbindex 4a47ea78c2..73a74466a0 100644--- a/spree/api/app/controllers/concerns/spree/api/v3/cart_resolvable.rb+++ b/spree/api/app/controllers/concerns/spree/api/v3/cart_resolvable.rb@@ -4,6 +4,8 @@ module Spreemodule CartResolvableextend ActiveSupport::Concern+ include Spree::Api::V3::PurchaseSerialization+protected# Find cart by prefixed ID and authorize read access (owner or guest@@ -73,9 +75,8 @@ module Spree# needs there.def render_order(status: :ok)record = @cart.reload- serializer = record.is_a?(Spree::OrderGroup) ? Spree.api.order_group_serializer : Spree.api.order_serializer- render json: serializer.new(record, params: serializer_params).to_h, status: status+ render json: purchase_serializer_for(record).new(record, params: serializer_params).to_h, status: statusend# Return the cart token from the request headers.diff --git a/spree/api/app/controllers/concerns/spree/api/v3/purchase_serialization.rb b/spree/api/app/controllers/concerns/spree/api/v3/purchase_serialization.rbnew file mode 100644index 0000000000..4327280ce8--- /dev/null+++ b/spree/api/app/controllers/concerns/spree/api/v3/purchase_serialization.rb@@ -0,0 +1,26 @@+module Spree+ module Api+ module V3+ # Which serializer describes what a checkout produced.+ #+ # A checkout answers with one record: the order it placed, or — when the+ # basket reached several sellers — the group holding one order per+ # seller. Which of the two it is follows the record, never the endpoint,+ # so every surface that resolves a checkout hands back the whole purchase+ # rather than one seller's share of it.+ module PurchaseSerialization+ extend ActiveSupport::Concern++ protected++ # @param record [Spree::Order, Spree::OrderGroup, Spree::Cart]+ # @return [Class] the serializer that describes it+ def purchase_serializer_for(record)+ return Spree.api.order_group_serializer if record.is_a?(Spree::OrderGroup)++ Spree.api.order_serializer+ end+ end+ end+ end+enddiff --git a/spree/api/app/controllers/spree/api/v3/store/orders_controller.rb b/spree/api/app/controllers/spree/api/v3/store/orders_controller.rbindex eb3e4ce077..b4392e9aa4 100644--- a/spree/api/app/controllers/spree/api/v3/store/orders_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/store/orders_controller.rb@@ -3,6 +3,8 @@ module Spreemodule V3module Storeclass OrdersController < Store::BaseController+ include Spree::Api::V3::PurchaseSerialization+# GET /api/v3/store/orders/:id# Single order lookup — accessible via order token (guests) or JWT (authenticated users)before_action :find_order!@@ -13,26 +15,61 @@ module Spreeprivate- # The cart's prefixed id stays the client's stable checkout handle:- # after completion it resolves here to the order created from that- # cart (Order#cart_id is unique; the order copies the cart token).+ # The cart's prefixed id stays the client's stable checkout handle.+ # A plain completion leaves the order it created carrying that id+ # (Order#cart_id is unique; the order copies the cart token). A+ # checkout that reached several sellers divided into one order per+ # seller and moved the id up to the group holding them, so the same+ # handle resolves to the group — a confirmation asking what its cart+ # became is answered with the whole purchase either way, never one+ # seller's share of it.+ #+ # The group's own id resolves here too, for a client re-reading what+ # completion handed back, the way +carts#complete+ already accepts it.def find_order!cart_pk = Spree::Cart.decode_own_prefixed_id(params[:id])- @order = cart_pk ? scope.find_by!(cart_id: cart_pk) : scope.find_by_prefix_id!(params[:id])+ @order = cart_pk ? find_by_cart!(cart_pk) : find_by_prefixed_id!(params[:id])+ end++ # @return [Spree::Order, Spree::OrderGroup]+ def find_by_cart!(cart_pk)+ scope.find_by(cart_id: cart_pk) || group_scope.find_by(cart_id: cart_pk) || not_found!+ end++ # @return [Spree::Order, Spree::OrderGroup]+ def find_by_prefixed_id!(id)+ scope.find_by_prefix_id(id) || group_scope.find_by_prefix_id(id) || not_found!end- # `market` and `fulfillments` are the withdrawal deadline's inputs and- # the serializer emits it on every response, so they are preloaded- # here rather than through `collection_includes` — this controller- # loads through `find_order!`, which never touches a collection.+ # Neither lookup answered. The caller asked `/orders`, so that is what+ # the 404 names — which of the two ran last is this endpoint's+ # business, and `order_not_found` is the code clients already handle.+ def not_found!+ raise ActiveRecord::RecordNotFound.new(nil, Spree::Order.name)+ end++ # Preloaded lazily, which `collection` would do for a list: this+ # controller loads through `find_order!`, so it asks for it itself.+ # Every association the serializer walks — items, parcels, their+ # rates and discounts — is then fetched once for all the rows that+ # need it, rather than once per row.def scopestorefront_access_policy.scope(current_store.orders.complete, token: order_token).- includes(:market, :fulfillments)+ preload_associations_lazily+ end++ # A group renders every child through the order serializer, so this+ # matters most here: without it each seller in the checkout adds its+ # own round of queries for the same associations.+ def group_scope+ storefront_access_policy.+ scope(current_store.order_groups, token: order_token).+ preload_associations_lazilyenddef serializer_class- Spree.api.order_serializer+ purchase_serializer_for(@order)endendenddiff --git a/spree/api/app/serializers/concerns/spree/api/v3/purchase_summary.rb b/spree/api/app/serializers/concerns/spree/api/v3/purchase_summary.rbnew file mode 100644index 0000000000..c65c33e90a--- /dev/null+++ b/spree/api/app/serializers/concerns/spree/api/v3/purchase_summary.rb@@ -0,0 +1,35 @@+module Spree+ module Api+ module V3+ # The money summary a cart, an order and a multi-seller purchase all+ # carry, declared once so a storefront renders any of them with one+ # component, and a fix to one is a fix to all three.+ #+ # Every amount is nulled for a guest the storefront hides prices from,+ # the payments' own included.+ module PurchaseSummary+ extend ActiveSupport::Concern++ included do+ typelize covered_by_store_credit: :boolean++ money_attributes :item_total, :display_item_total,+ :discount_total, :display_discount_total,+ :tax_total, :display_tax_total,+ :included_tax_total, :display_included_tax_total,+ :additional_tax_total, :display_additional_tax_total,+ :delivery_total, :display_delivery_total,+ :fee_total, :display_fee_total,+ :gift_card_total, :display_gift_card_total,+ :store_credit_total, :display_store_credit_total,+ :total, :display_total,+ :amount_due, :display_amount_due++ attribute :covered_by_store_credit, &:covered_by_store_credit?++ many :payments, resource: proc { Spree.api.payment_serializer }+ end+ end+ end+ end+enddiff --git a/spree/api/app/serializers/spree/api/v3/admin/refund_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/refund_serializer.rbindex dfc751a868..4001d31bdc 100644--- a/spree/api/app/serializers/spree/api/v3/admin/refund_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/refund_serializer.rb@@ -3,6 +3,9 @@ module Spreemodule V3module Adminclass RefundSerializer < V3::RefundSerializer+ # The Store API keeps this deprecated name until 6.1.+ _attributes.delete(:reimbursement_id)+typelize payment_id: [:string, nullable: true],refund_reason_id: [:string, nullable: true],refunder_id: [:string, nullable: true],diff --git a/spree/api/app/serializers/spree/api/v3/admin/stock_location_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/stock_location_serializer.rbindex ba686af783..45cf17d1d9 100644--- a/spree/api/app/serializers/spree/api/v3/admin/stock_location_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/admin/stock_location_serializer.rb@@ -3,6 +3,9 @@ module Spreemodule V3module Adminclass StockLocationSerializer < V3::StockLocationSerializer+ # The Store API keeps these deprecated names until 6.1.+ %i[country_iso state_abbr].each { |key| _attributes.delete(key) }+include Concerns::ExternalReferencesAttributetypelize seller_id: [:string, nullable: true], seller_name: [:string, nullable: true],diff --git a/spree/api/app/serializers/spree/api/v3/cart_serializer.rb b/spree/api/app/serializers/spree/api/v3/cart_serializer.rbindex ae2231a36b..c54723a65d 100644--- a/spree/api/app/serializers/spree/api/v3/cart_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/cart_serializer.rb@@ -15,8 +15,7 @@ module Spreeorder_minimum_shortfall: [:string, nullable: true], below_order_minimum: ['boolean | null'],freight_summary: [:FreightSummary, nullable: true],requirements: 'Array<{step: string, field: string, code: string, message: string}>',- store_credit_total: [:string, nullable: true], display_store_credit_total: [:string, nullable: true],- covered_by_store_credit: :boolean, shipping_eq_billing_address: :boolean,+ shipping_eq_billing_address: :boolean,warnings: 'Array<{code: string, message: string, line_item_id?: string, variant_id?: string, item_index?: number}>',billing_address: { nullable: true }, shipping_address: { nullable: true },gift_card: { nullable: true }, market: { nullable: true }@@ -59,25 +58,8 @@ module Spree# Nulled for gated (prices_hidden) guests so the cart can't leak the# prices that product/variant serializers already withhold.- money_attributes :item_total, :display_item_total,- :adjustment_total, :display_adjustment_total,- :discount_total, :display_discount_total,- :tax_total, :display_tax_total, :included_tax_total, :display_included_tax_total,- :additional_tax_total, :display_additional_tax_total, :total, :display_total,- :gift_card_total, :display_gift_card_total,- :amount_due, :display_amount_due,- :delivery_total, :display_delivery_total,- :fee_total, :display_fee_total-- attribute :store_credit_total do |order|- Spree::Money::Rounding.format(order.total_applied_store_credit, order.currency) unless params[:hide_prices]- end-- attribute :display_store_credit_total do |order|- order.display_total_applied_store_credit.to_s unless params[:hide_prices]- end-- attribute :covered_by_store_credit, &:covered_by_store_credit?+ include Spree::Api::V3::PurchaseSummary+ money_attributes :adjustment_total, :display_adjustment_totalattribute :current_step do |order|order.current_checkout_step@@ -136,7 +118,6 @@ module Spreemany :fees, resource: proc { Spree.api.fee_serializer }many :line_items, key: :items, resource: proc { Spree.api.line_item_serializer }many :fulfillments, resource: proc { Spree.api.fulfillment_serializer }- many :payments, resource: proc { Spree.api.payment_serializer }one :billing_address, resource: proc { Spree.api.address_serializer }one :shipping_address, resource: proc { Spree.api.address_serializer }diff --git a/spree/api/app/serializers/spree/api/v3/order_group_serializer.rb b/spree/api/app/serializers/spree/api/v3/order_group_serializer.rbindex 88f42e2463..d24fed5632 100644--- a/spree/api/app/serializers/spree/api/v3/order_group_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/order_group_serializer.rb@@ -16,7 +16,10 @@ module Spreeattributes :number, :email, :currency- money_attributes :total, :display_total, :item_total, :display_item_total+ # Every figure is rolled up from the children, never prorated back+ # down. The payments are the group's own: a split checkout pays once,+ # against the group, so a child holds none.+ include Spree::Api::V3::PurchaseSummary# Rolled up across the children rather than stored, so it can never# disagree with the orders it describes.@@ -29,6 +32,12 @@ module Spreeone :billing_address, resource: proc { Spree.api.address_serializer }one :shipping_address, resource: proc { Spree.api.address_serializer }+ # The card itself is deliberately not nested here — the split copies it+ # onto every child, so it is already in the payload, and a group this+ # deep pushes the generated Zod schema past what TypeScript will+ # serialize into a declaration file. `gift_card_total` is the figure a+ # summary needs, and only the group can answer it.+# The whole point of the group: the customer sees one purchase, and the# seller orders inside it are how it will arrive.many :orders, resource: proc { Spree.api.order_serializer }diff --git a/spree/api/app/serializers/spree/api/v3/order_serializer.rb b/spree/api/app/serializers/spree/api/v3/order_serializer.rbindex e749bb550f..1b4dc617d2 100644--- a/spree/api/app/serializers/spree/api/v3/order_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/order_serializer.rb@@ -13,8 +13,7 @@ module Spreecoupon_code: [:string, nullable: true],fulfillment_status: [:string, nullable: true, enum: Spree::Order::FULFILLMENT_STATUSES],payment_status: [:string, nullable: true, enum: Spree::Order::PAYMENT_STATUSES],- store_credit_total: [:string, nullable: true], display_store_credit_total: [:string, nullable: true],- covered_by_store_credit: :boolean, completed_at: [:string, nullable: true],+ completed_at: [:string, nullable: true],withdrawal_period_ends_at: [:string, nullable: true], within_withdrawal_period: :boolean,billing_address: { nullable: true }, shipping_address: { nullable: true },gift_card: { nullable: true }, market: { nullable: true }@@ -64,25 +63,8 @@ module Spree# Nulled for gated (prices_hidden) guests, consistent with cart and# catalog price hiding.- money_attributes :item_total, :display_item_total,- :adjustment_total, :display_adjustment_total,- :discount_total, :display_discount_total,- :tax_total, :display_tax_total, :included_tax_total, :display_included_tax_total,- :additional_tax_total, :display_additional_tax_total, :total, :display_total,- :gift_card_total, :display_gift_card_total,- :amount_due, :display_amount_due,- :delivery_total, :display_delivery_total,- :fee_total, :display_fee_total-- attribute :store_credit_total do |order|- Spree::Money::Rounding.format(order.total_applied_store_credit, order.currency) unless params[:hide_prices]- end-- attribute :display_store_credit_total do |order|- order.display_total_applied_store_credit.to_s unless params[:hide_prices]- end-- attribute :covered_by_store_credit, &:covered_by_store_credit?+ include Spree::Api::V3::PurchaseSummary+ money_attributes :adjustment_total, :display_adjustment_totalmany :order_promotions, key: :discounts, resource: proc { Spree.api.applied_promotion_serializer }# Itemized charges (duties, surcharges, COD, handling) — see the cart@@ -90,7 +72,6 @@ module Spreemany :fees, resource: proc { Spree.api.fee_serializer }many :line_items, key: :items, resource: proc { Spree.api.line_item_serializer }many :fulfillments, resource: proc { Spree.api.fulfillment_serializer }- many :payments, resource: proc { Spree.api.payment_serializer }one :billing_address, resource: proc { Spree.api.address_serializer }one :shipping_address, resource: proc { Spree.api.address_serializer }one :gift_card, resource: proc { Spree.api.gift_card_serializer }diff --git a/spree/api/app/serializers/spree/api/v3/refund_serializer.rb b/spree/api/app/serializers/spree/api/v3/refund_serializer.rbindex 96c3470e2a..fcdeee7a11 100644--- a/spree/api/app/serializers/spree/api/v3/refund_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/refund_serializer.rb@@ -6,7 +6,8 @@ module Spreeclass RefundSerializer < BaseSerializertypelize transaction_id: [:string, nullable: true],payment_id: [:string, nullable: true], refund_reason_id: [:string, nullable: true],- originator_id: [:string, nullable: true], originator_type: [:string, nullable: true]+ originator_id: [:string, nullable: true], originator_type: [:string, nullable: true],+ reimbursement_id: [:string, nullable: true, deprecated: 'Always null: reimbursements are gone. Use `originator_id`. Removed in 6.1.']attributes :transaction_id@@ -21,6 +22,10 @@ module Spreeattribute :originator_type do |refund|Spree::Base.polymorphic_api_type(refund.originator_type)end++ # @deprecated Reimbursements were folded into returns, which a refund+ # names as its +originator+. Removed in 6.1.+ attribute(:reimbursement_id) { nil }endendenddiff --git a/spree/api/app/serializers/spree/api/v3/seller/stock_location_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/stock_location_serializer.rbindex 605cb59399..5a90855c75 100644--- a/spree/api/app/serializers/spree/api/v3/seller/stock_location_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/seller/stock_location_serializer.rb@@ -3,6 +3,9 @@ module Spreemodule V3module Sellerclass StockLocationSerializer < V3::StockLocationSerializer+ # The Store API keeps these deprecated names until 6.1.+ %i[country_iso state_abbr].each { |key| _attributes.delete(key) }+typelize address2: [:string, nullable: true], state_name: [:string, nullable: true],phone: [:string, nullable: true], company: [:string, nullable: true],active: :boolean, default: :boolean, kind: [:string, enum: Spree::StockLocation::KINDS, enum_type_name: 'StockLocationKind'],diff --git a/spree/api/app/serializers/spree/api/v3/stock_location_serializer.rb b/spree/api/app/serializers/spree/api/v3/stock_location_serializer.rbindex c48f6d762f..4b41f1ed49 100644--- a/spree/api/app/serializers/spree/api/v3/stock_location_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/stock_location_serializer.rb@@ -6,11 +6,18 @@ module Spreezipcode: [:string, nullable: true], country_code: [:string, nullable: true, enum: Spree::IsoData.country_codes, enum_type_name: 'CountryCode'],country_name: [:string, nullable: true], state_code: [:string, nullable: true],state_text: [:string, nullable: true],+ country_iso: [:string, nullable: true, deprecated: 'Use `country_code`. Removed in 6.1.'],+ state_abbr: [:string, nullable: true, deprecated: 'Use `state_code`. Removed in 6.1.'],pickup_ready_in_minutes: [:number, nullable: true],pickup_instructions: [:string, nullable: true]attributes :name, :address1, :city, :zipcode, :country_code, :country_name, :state_code, :state_text+ # @deprecated Storefronts shipped against these names; use +country_code++ # and +state_code+. Removed in 6.1.+ attribute :country_iso, &:country_code+ attribute :state_abbr, &:state_code+# Collection details the customer needs when choosing a counter: how# long until the order is ready, and where to go. This serializer# backs the pickup-locations endpoint, so without them the twodiff --git a/spree/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rbindex afc5a1b095..656a7042a3 100644--- a/spree/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/store/orders_controller_spec.rb@@ -61,6 +61,88 @@ RSpec.describe Spree::Api::V3::Store::OrdersController, type: :controller doendend+ # A basket that reached several sellers divided into one order per seller+ # and the cart handle moved up to the group holding them, so no order+ # carries it any more. The confirmation page asks with the handle it has+ # and has to be given the whole purchase.+ context 'with the cart handle after a checkout that split across sellers' do+ let(:cart) { create(:cart_with_line_items, store: store) }+ let!(:group) do+ create(:order_group, :with_parcels, store: store, customer: nil, cart: cart, token: cart.token)+ end++ before do+ cart.update_columns(completed_at: Time.current)+ request.headers['x-spree-token'] = cart.token+ end++ it 'resolves the cart handle to the group' do+ get :show, params: { id: cart.prefixed_id }++ expect(response).to have_http_status(:ok)+ expect(json_response['id']).to eq(group.prefixed_id)+ expect(json_response['number']).to eq(group.number)+ end++ it 'answers with every seller’s items rather than one order’s' do+ get :show, params: { id: cart.prefixed_id }++ expect(json_response['orders'].size).to eq(2)+ expect(json_response['orders'].sum { |order| order['items'].size }).to eq(2)+ end++ it 'sums the delivery the children were quoted' do+ get :show, params: { id: cart.prefixed_id }++ expect(BigDecimal(json_response['delivery_total'])).+ to eq(group.orders.sum(&:delivery_total))+ end++ it 'carries the payment the group was charged, which no child holds' do+ payment = create(:payment, order: nil, order_group: group, amount: group.total)++ get :show, params: { id: cart.prefixed_id }++ expect(json_response['payments'].map { |row| row['id'] }).to eq([payment.prefixed_id])+ expect(json_response['orders'].flat_map { |order| order['payments'] }).to be_empty+ end++ # Completion hands the client a group id; re-reading with it must work+ # the same way +carts#complete+ already accepts it on retry.+ it 'resolves the group’s own id too' do+ get :show, params: { id: group.prefixed_id }++ expect(response).to have_http_status(:ok)+ expect(json_response['id']).to eq(group.prefixed_id)+ end++ it 'returns not found without the matching token' do+ request.headers['x-spree-token'] = 'wrong-token'++ get :show, params: { id: cart.prefixed_id }++ expect(response).to have_http_status(:not_found)+ end++ it 'runs no more queries for a checkout that reached more sellers' do+ larger_cart = create(:cart_with_line_items, store: store)+ larger_cart.update_columns(completed_at: Time.current)+ create(:order_group, :with_parcels, store: store, customer: nil, cart: larger_cart,+ token: larger_cart.token, sellers_count: 3)++ count_queries = lambda do |handle, token|+ request.headers['x-spree-token'] = token+ queries = 0+ counter = ->(*, payload) { queries += 1 unless payload[:name] == 'SCHEMA' || payload[:sql].match?(/\A(BEGIN|COMMIT|SAVEPOINT|RELEASE)/) }+ ActiveSupport::Notifications.subscribed(counter, 'sql.active_record') { get :show, params: { id: handle } }+ queries+ end++ expect(count_queries.call(larger_cart.prefixed_id, larger_cart.token)).+ to eq(count_queries.call(cart.prefixed_id, cart.token))+ end+ end+context 'with spree token' dolet(:guest_order) { create(:completed_order_with_totals, customer: nil, store: store) }diff --git a/spree/api/spec/integration/spree/api/v3/store/orders_spec.rb b/spree/api/spec/integration/spree/api/v3/store/orders_spec.rbindex 1327e71458..20dc5dc197 100644--- a/spree/api/spec/integration/spree/api/v3/store/orders_spec.rb+++ b/spree/api/spec/integration/spree/api/v3/store/orders_spec.rb@@ -12,7 +12,18 @@ RSpec.describe 'Orders API', type: :request, swagger_doc: 'api-reference/store.ytags 'Orders'produces 'application/json'security [api_key: [], bearer_auth: []]- description 'Returns a single completed order by prefixed ID. Accessible via JWT (authenticated users) or order token header (guests).'+ description <<~DESCRIPTION+ Returns a completed purchase. Accessible via JWT (authenticated users) or order token header (guests).++ Resolves three kinds of id: the order's own (`or_…`), the id of the cart it was placed from, and the+ id of an order group (`ogrp_…`). The cart's id is the handle a storefront keeps through checkout, so+ a confirmation page can ask what its cart became without having learned a new one.++ A checkout that reached several sellers divided into one order per seller, and the cart moved up to+ the group holding them — so that handle, and the group's own id, answer with the **order group**,+ with the per-seller orders nested inside it. Every other lookup answers with an **order**. The two+ are told apart by the id prefix (`ogrp_` vs `or_`), or by the presence of `orders`.+ DESCRIPTIONsdk_example 'orders/get'@@ -20,7 +31,7 @@ RSpec.describe 'Orders API', type: :request, swagger_doc: 'api-reference/store.yparameter name: 'Authorization', in: :header, type: :string, required: false,description: 'Bearer token for authenticated customers'parameter name: :id, in: :path, type: :string, required: true,- description: 'Order prefixed ID'+ description: 'Prefixed ID of the order, of the cart it was placed from, or of its order group'parameter name: 'x-spree-token', in: :header, type: :string, required: false,description: 'Order token for guest access'parameter name: :expand, in: :query, type: :string, required: false,diff --git a/spree/api/spec/serializers/spree/api/v3/money_contract_spec.rb b/spree/api/spec/serializers/spree/api/v3/money_contract_spec.rbindex b8d117568f..f05cced8e8 100644--- a/spree/api/spec/serializers/spree/api/v3/money_contract_spec.rb+++ b/spree/api/spec/serializers/spree/api/v3/money_contract_spec.rb@@ -100,11 +100,14 @@ RSpec.describe 'API v3 money contract' doit 'leaves formatted money out of the Admin and Seller APIs, nested records included' doorder = create(:completed_order_with_totals, store: store)variant = order.line_items.first.variant+ group = create(:order_group, :with_parcels, store: store, sellers_count: 2)+ create(:payment, order: nil, order_group: group, amount: group.reload.total)expand = { expand: %w[prices default_variant variants line_items] }found = {Spree::Api::V3::Admin::OrderSerializer => order,Spree::Api::V3::Seller::OrderSerializer => order,+ Spree::Api::V3::Admin::OrderGroupSerializer => group,Spree::Api::V3::Admin::ProductSerializer => variant.product,Spree::Api::V3::Seller::ProductSerializer => variant.product,Spree::Api::V3::Admin::VariantSerializer => variant,diff --git a/spree/api/spec/serializers/spree/api/v3/price_gating_spec.rb b/spree/api/spec/serializers/spree/api/v3/price_gating_spec.rbindex 97419b6012..4c664be4b2 100644--- a/spree/api/spec/serializers/spree/api/v3/price_gating_spec.rb+++ b/spree/api/spec/serializers/spree/api/v3/price_gating_spec.rb@@ -122,6 +122,27 @@ RSpec.describe 'v3 Store serializer price gating' doendend+ describe Spree::Api::V3::OrderGroupSerializer do+ let(:group) { create(:order_group, :with_parcels, store: store) }++ before { create(:payment, order: nil, order_group: group, amount: group.reload.total, status: 'completed') }++ it 'nulls the summary and the payment amounts for gated guests' do+ hash = serialize(described_class, Spree::OrderGroup.find(group.id), hide: true)++ expect(hash.values_at('total', 'amount_due', 'store_credit_total', 'gift_card_total')).to all(be_nil)+ expect(hash['payments'].map { |payment| payment['amount'] }).to eq([nil])+ end++ # Written as every other amount is: to the currency's decimals.+ it 'writes the store credit total as canonical money when not gated' do+ hash = serialize(described_class, Spree::OrderGroup.find(group.id), hide: false)++ expect(hash['store_credit_total']).to eq('0.00')+ expect(hash['amount_due']).to eq('0.00')+ end+ end+# Nested records embedded in a cart/order must honor hide_prices too, so a# gated guest can't recover amounts through discounts, payments, fulfillments,# or an applied gift card.diff --git a/spree/api/spec/serializers/spree/api/v3/refund_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/refund_serializer_spec.rbindex b52cb535d6..6d6a8d202d 100644--- a/spree/api/spec/serializers/spree/api/v3/refund_serializer_spec.rb+++ b/spree/api/spec/serializers/spree/api/v3/refund_serializer_spec.rb@@ -12,7 +12,7 @@ RSpec.describe Spree::Api::V3::RefundSerializer doit 'includes all expected attributes' doexpect(subject.keys).to match_array(%w[- id amount transaction_id payment_id refund_reason_id originator_id originator_type+ id amount transaction_id payment_id refund_reason_id originator_id originator_type reimbursement_id])end@@ -26,6 +26,11 @@ RSpec.describe Spree::Api::V3::RefundSerializer doendend+ it 'keeps the deprecated reimbursement_id, always null, until 6.1' do+ expect(subject['reimbursement_id']).to be_nil+ expect(Spree::Api::V3::Admin::RefundSerializer.new(refund, params: base_params).to_h).not_to have_key('reimbursement_id')+ end+it 'returns the prefixed id' doexpect(subject['id']).to eq(refund.prefixed_id)enddiff --git a/spree/api/spec/serializers/spree/api/v3/stock_location_serializer_spec.rb b/spree/api/spec/serializers/spree/api/v3/stock_location_serializer_spec.rbnew file mode 100644index 0000000000..533c0cec9c--- /dev/null+++ b/spree/api/spec/serializers/spree/api/v3/stock_location_serializer_spec.rb@@ -0,0 +1,18 @@+require 'spec_helper'++RSpec.describe Spree::Api::V3::StockLocationSerializer do+ let(:stock_location) { build(:stock_location, country_code: 'US', state_code: 'DC') }++ subject { described_class.new(stock_location, params: { store: @default_store, currency: 'USD' }).to_h }++ it 'keeps the 5.6 names for the country and state codes until 6.1' do+ expect(subject).to include('country_code' => 'US', 'country_iso' => 'US', 'state_code' => 'DC', 'state_abbr' => 'DC')+ end++ it 'leaves the deprecated names out of the Admin and Seller APIs' do+ [Spree::Api::V3::Admin::StockLocationSerializer, Spree::Api::V3::Seller::StockLocationSerializer].each do |serializer|+ expect(serializer.new(stock_location, params: { store: @default_store, currency: 'USD' }).to_h.keys).+ not_to include('country_iso', 'state_abbr')+ end+ end+enddiff --git a/spree/core/app/models/concerns/spree/derived_number.rb b/spree/core/app/models/concerns/spree/derived_number.rbindex 7e2e0df587..17f995d4fb 100644--- a/spree/core/app/models/concerns/spree/derived_number.rb+++ b/spree/core/app/models/concerns/spree/derived_number.rb@@ -43,24 +43,22 @@ module Spree# unsaved record sorts last, which is what a merchant watching a new row# appear expects.def position_among_siblings- scope = sibling_scope- return 1 if scope.nil?+ parent = owner+ association = sibling_association_name+ return 1 if parent.nil? || !parent.respond_to?(association)- earlier = id.nil? ? scope.count : scope.where(scope.arel_table[:id].lt(id)).count+ earlier = if id.present? && parent.read_association_in_memory?(association)+ parent.public_send(association).to_a.count { |sibling| sibling.id.present? && sibling.id < id }+ else+ scope = parent.public_send(association).unscope(:order)+ id.nil? ? scope.count : scope.where(scope.arel_table[:id].lt(id)).count+ endearlier + 1end- # The siblings sharing this record's parent. Nil when there is no parent- # to group by.- def sibling_scope- parent = owner- return if parent.nil?-- association = self.class.name.demodulize.underscore.pluralize- return unless parent.respond_to?(association)-- parent.public_send(association).unscope(:order)+ def sibling_association_name+ self.class.name.demodulize.underscore.pluralizeendendenddiff --git a/spree/core/app/models/concerns/spree/purchase/store_credits.rb b/spree/core/app/models/concerns/spree/purchase/store_credits.rbindex cc21df448e..9d3f51d81b 100644--- a/spree/core/app/models/concerns/spree/purchase/store_credits.rb+++ b/spree/core/app/models/concerns/spree/purchase/store_credits.rb@@ -58,7 +58,7 @@ module Spree# @return [BigDecimal]def total_applied_store_credit- if payments.loaded?+ if read_association_in_memory?(:payments)payments.find_all(&:store_credit?).reject(&:has_invalid_status?).@@ -68,10 +68,32 @@ module Spreeendend+ # Balance still to collect, never negative. Store credit already applied+ # but not yet captured is taken off; captured credit is a completed+ # payment, so the balance has counted it already.+ #+ # @return [BigDecimal]+ def amount_due+ [outstanding_balance - uncaptured_store_credit, 0].max+ end++ # What store credit paid, apart from gift cards. A gift card is redeemed+ # as store credit, but it is reported on its own as +gift_card_total+, so+ # a summary showing both rows deducts each amount once.+ #+ # @return [BigDecimal]+ def store_credit_total+ total_applied_store_credit - gift_card_total+ end+def using_store_credit?total_applied_store_credit > 0end+ def display_store_credit_total+ Spree::Money.new(-store_credit_total, currency: currency)+ end+def display_total_applicable_store_creditSpree::Money.new(-total_applicable_store_credit, currency: currency)end@@ -95,6 +117,19 @@ module Spreedef display_total_minus_store_creditsSpree::Money.new(total_minus_store_credits, currency: currency)end++ private++ # @return [BigDecimal]+ def uncaptured_store_credit+ if read_association_in_memory?(:payments)+ payments.+ select { |payment| payment.store_credit? && !payment.has_invalid_status? && !payment.completed? }.+ sum(BigDecimal('0'), &:amount)+ else+ payments.store_credits.valid.where.not(status: 'completed').sum(:amount)+ end+ endendendenddiff --git a/spree/core/app/models/concerns/spree/purchase/totals.rb b/spree/core/app/models/concerns/spree/purchase/totals.rbindex 42686b4479..c4a0148c16 100644--- a/spree/core/app/models/concerns/spree/purchase/totals.rb+++ b/spree/core/app/models/concerns/spree/purchase/totals.rb@@ -75,13 +75,6 @@ module Spreeoutstanding_balance != 0end- # Balance still to collect after applied store credit, never negative.- #- # @return [BigDecimal]- def amount_due- [outstanding_balance - total_applied_store_credit, 0].max- end-# @return [Boolean]def paid?total.positive? && payment_total >= totaldiff --git a/spree/core/app/models/spree/base.rb b/spree/core/app/models/spree/base.rbindex 8f31ca0a1b..0ef053f01f 100644--- a/spree/core/app/models/spree/base.rb+++ b/spree/core/app/models/spree/base.rb@@ -69,6 +69,18 @@ class Spree::Base < ApplicationRecordtrueend+ # Whether to answer from an association's rows rather than a query of its+ # own (a SUM, an EXISTS). True when the rows are loaded already, or when+ # this record came from a list loaded with +preload_associations_lazily+:+ # loading them then fetches the rows for the whole list in one query, where+ # an aggregate would run once per record.+ #+ # @param name [Symbol] the association+ # @return [Boolean]+ def read_association_in_memory?(name)+ association(name).loaded? || lazy_preload_context.present?+ end+# @see Spree.mysql? — the single definition; this reads it so a model can# branch without reaching for the connection itself.def mysql_adapter?diff --git a/spree/core/app/models/spree/delivery_rate.rb b/spree/core/app/models/spree/delivery_rate.rbindex fcab2a7490..984641d36a 100644--- a/spree/core/app/models/spree/delivery_rate.rb+++ b/spree/core/app/models/spree/delivery_rate.rb@@ -157,7 +157,7 @@ module Spreeenddef discount_amount- fulfillment.discounts.promotion.sum(:amount)+ fulfillment.promotion_discount_totalendendenddiff --git a/spree/core/app/models/spree/fulfillment.rb b/spree/core/app/models/spree/fulfillment.rbindex ec118c3932..7ea75af444 100644--- a/spree/core/app/models/spree/fulfillment.rb+++ b/spree/core/app/models/spree/fulfillment.rb@@ -374,9 +374,20 @@ module Spree## @return [Boolean]def with_free_shipping_promotion?+ return discounts.any?(&:promotion?) if read_association_in_memory?(:discounts)+discounts.promotion.exists?end+ # What promotions took off this shipment's cost, as a negative amount.+ #+ # @return [BigDecimal]+ def promotion_discount_total+ return discounts.select(&:promotion?).sum(BigDecimal('0'), &:amount) if read_association_in_memory?(:discounts)++ discounts.promotion.sum(:amount)+ end+# Placement no longer moves physical stock — the units are promised in# Spree::Orders::Complete and only leave the shelf when the parcel does.def finalize!@@ -701,7 +712,7 @@ module Spree## @return [Spree::Delivery, nil]def primary_delivery- deliveries.first+ read_association_in_memory?(:deliveries) ? deliveries.to_a.first : deliveries.firstend# The primary delivery's tracking number. Read-only since 6.0: tracking isdiff --git a/spree/core/app/models/spree/order.rb b/spree/core/app/models/spree/order.rbindex acd87c13a9..0a6883787f 100644--- a/spree/core/app/models/spree/order.rb+++ b/spree/core/app/models/spree/order.rb@@ -459,7 +459,7 @@ module Spreeenddef refunds_total- refunds.loaded? ? refunds.sum(&:amount) : refunds.sum(:amount)+ read_association_in_memory?(:refunds) ? refunds.sum(0.to_d, &:amount) : refunds.sum(:amount)end# Checks if the order is partially refunded@@ -708,7 +708,7 @@ module Spree## @return [BigDecimal]def returned_items_refund_total- return refunds.select(&:for_returned_items?).sum(0.to_d, &:amount) if refunds.loaded?+ return refunds.select(&:for_returned_items?).sum(0.to_d, &:amount) if read_association_in_memory?(:refunds)refunds.for_returned_items.sum(:amount)enddiff --git a/spree/core/app/models/spree/order_group.rb b/spree/core/app/models/spree/order_group.rbindex 7032f7e2e2..c3fcb243b6 100644--- a/spree/core/app/models/spree/order_group.rb+++ b/spree/core/app/models/spree/order_group.rb@@ -100,9 +100,14 @@ module Spree# the children loaded already (a serializer renders them, a gateway call# reads four of these in a row), and an aggregate per figure would issue a# query each time even against rows sitting in memory.+ #+ # +tax_total+ is each child's own derivation rather than a column, summed+ # like the rest: asking the children keeps the group's answer the one they+ # gave, where re-deriving it here from the two halves above would be a+ # second way to reach the same figure.ROLLED_UP_TOTALS = %i[total item_total delivery_total additional_tax_total included_tax_total- discount_total fee_total+ tax_total discount_total fee_total].freezeROLLED_UP_TOTALS.each do |figure|@@ -112,7 +117,7 @@ module Spreeendmoney_methods(*ROLLED_UP_TOTALS)- money_methods :gift_card_total+ money_methods :gift_card_total, :amount_duealias ship_total delivery_totaldiff --git a/spree/core/app/models/spree/variant.rb b/spree/core/app/models/spree/variant.rbindex 9403d60ab7..81f841d4d6 100644--- a/spree/core/app/models/spree/variant.rb+++ b/spree/core/app/models/spree/variant.rb@@ -663,7 +663,7 @@ module Spreedef price_in(currency)currency = currency&.upcase- price = if prices.loaded? && prices.any?+ price = if read_association_in_memory?(:prices) && prices.any?prices.detect { |p| p.currency == currency && p.price_list_id.nil? }elseprices.base_prices.find_by(currency: currency)diff --git a/spree/core/spec/models/concerns/spree/purchase/gift_cards_spec.rb b/spree/core/spec/models/concerns/spree/purchase/gift_cards_spec.rbindex 5b5d2f496f..0a6b783176 100644--- a/spree/core/spec/models/concerns/spree/purchase/gift_cards_spec.rb+++ b/spree/core/spec/models/concerns/spree/purchase/gift_cards_spec.rb@@ -10,6 +10,13 @@ RSpec.shared_examples 'a gift cards host' doexpect(record.gift_card_total).to eq(gift_card.amount)expect(record.total_minus_gift_cards).to eq(record.total - gift_card.amount)end++ # A gift card is redeemed as store credit; reporting it in both totals+ # would have a summary deduct it twice.+ it 'is left out of the store credit total' do+ expect(record.total_applied_store_credit).to eq(gift_card.amount)+ expect(record.store_credit_total).to eq(0)+ endenddescribe '#apply_gift_card' dodiff --git a/spree/core/spec/models/concerns/spree/purchase/store_credits_spec.rb b/spree/core/spec/models/concerns/spree/purchase/store_credits_spec.rbindex 1f22bf4466..e18bb8a814 100644--- a/spree/core/spec/models/concerns/spree/purchase/store_credits_spec.rb+++ b/spree/core/spec/models/concerns/spree/purchase/store_credits_spec.rb@@ -444,6 +444,31 @@ RSpec.shared_examples 'a store credits host' doendend+ describe '#amount_due' do+ let(:record) { new_record(customer: create(:user), total: 100) }++ it 'takes off store credit applied but not captured yet' do+ create_store_credit_payment(record, status: 'checkout', amount: 30)++ expect(record.amount_due).to eq(70)+ end++ # Captured credit is a completed payment, so the balance counts it already.+ it 'takes captured store credit off once' do+ create_store_credit_payment(record, status: 'completed', amount: 30)+ record.update_columns(payment_total: 30)++ expect(record.amount_due).to eq(70)+ end++ it 'never goes negative' do+ create_store_credit_payment(record, status: 'checkout', amount: 30)+ record.update_columns(payment_total: 90)++ expect(record.amount_due).to eq(0)+ end+ end+describe '#using_store_credit?' dosubject { new_record }diff --git a/spree/core/spec/models/concerns/spree/purchase/totals_spec.rb b/spree/core/spec/models/concerns/spree/purchase/totals_spec.rbindex 6ff390d175..07f6de8db4 100644--- a/spree/core/spec/models/concerns/spree/purchase/totals_spec.rb+++ b/spree/core/spec/models/concerns/spree/purchase/totals_spec.rb@@ -41,18 +41,6 @@ RSpec.shared_examples 'a purchase totals host' doendend- describe '#amount_due' do- it 'nets applied store credit and never goes negative' do- record = new_record(total: 100, payment_total: 40)-- allow(record).to receive(:total_applied_store_credit).and_return(70)- expect(record.amount_due).to eq(0)-- allow(record).to receive(:total_applied_store_credit).and_return(10)- expect(record.amount_due).to eq(50)- end- end-describe '#fulfillment_discount' doit 'sums fulfillment-attached discounts as a positive amount' dorecord = new_record_with_line_itemsdiff --git a/spree/core/spec/models/spree/order_group_spec.rb b/spree/core/spec/models/spree/order_group_spec.rbindex 6da25f7a4f..1dcae8d471 100644--- a/spree/core/spec/models/spree/order_group_spec.rb+++ b/spree/core/spec/models/spree/order_group_spec.rb@@ -19,6 +19,65 @@ RSpec.describe Spree::OrderGroup, type: :model doendend+ describe '#tax_total' do+ # Each child's own tax, summed — and so equal to the two halves the group+ # rolls up separately, which is what a summary adds beside them.+ it 'is what the children were taxed, in the one figure a summary shows' do+ create(:order, store: store, order_group: group, included_tax_total: 2, additional_tax_total: 3)+ create(:order, store: store, order_group: group, seller: seller, included_tax_total: 1, additional_tax_total: 4)++ group.reload++ expect(group.tax_total).to eq(10)+ expect(group.tax_total).to eq(group.included_tax_total + group.additional_tax_total)+ end++ it 'is zero when nothing was taxed' do+ expect(create(:order_group, store: store).tax_total).to eq(0)+ end+ end++ describe '#amount_due' do+ let(:group) { create(:order_group, :with_parcels, store: store, sellers_count: 2) }+ let(:total) { group.reload.total }++ # Read through a fresh instance: a group memoizes its derived money, and+ # validating a payment against one computes that before the payment it is+ # about to hold exists.+ def settled = described_class.find(group.id)++ it 'is the whole purchase while nothing has been collected' do+ expect(settled.amount_due).to eq(total)+ end++ it 'is nothing once the payment the group holds covers it' do+ create(:payment, order: nil, order_group: group, amount: total, status: 'completed')++ expect(settled.amount_due).to eq(0)+ end++ # Store credit is applied against the group, so only the group can take it+ # off — a child reads no payments at all and would report the full amount.+ # The credit is captured, so the 30 is already counted as paid; the card+ # still owes the rest.+ it 'counts captured store credit once while the rest is still owed' do+ store_credit = create(:store_credit, store: store, customer: group.customer, amount: 30)+ create(:store_credit_payment, order: nil, order_group: group, source: store_credit,+ amount: 30, status: 'completed')+ create(:payment, order: nil, order_group: group, amount: total - 30, status: 'pending')++ expect(settled.amount_due).to eq(total - 30)+ end++ it 'takes applied store credit off, and never goes negative' do+ store_credit = create(:store_credit, store: store, customer: group.customer, amount: total)+ create(:store_credit_payment, order: nil, order_group: group, source: store_credit,+ amount: total, status: 'completed')++ expect(settled.amount_due).to eq(0)+ end+ end+describe '#fulfillment_status' doit 'is nil while no child has one' docreate(:order, store: store, order_group: group)diff --git a/spree/emails/app/serializers/spree/emails/order_group_serializer.rb b/spree/emails/app/serializers/spree/emails/order_group_serializer.rbindex 34c8407406..c74998be9d 100644--- a/spree/emails/app/serializers/spree/emails/order_group_serializer.rb+++ b/spree/emails/app/serializers/spree/emails/order_group_serializer.rb@@ -40,6 +40,8 @@ module Spreegroup.display_gift_card_total.to_send+ many :payments, resource: Spree::Emails::PaymentSerializer+# Every child order in full is what the webhook payload carries; the# email reads the purchase-wide fields above instead.many :orders, resource: proc { Spree.api.order_serializer }, if: proc { false }