Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Removed formatted money fields from email template data (#14884)

Damian Legawiec9736316f970d
diff --git a/.changeset/email-types-without-display-money.md b/.changeset/email-types-without-display-money.md
new file mode 100644
index 0000000000..de5d6892b5
--- /dev/null
+++ b/.changeset/email-types-without-display-money.md
@@ -0,0 +1,6 @@
+---
+"@spree/dashboard": patch
+"@spree/admin-sdk": patch
+---
+
+Removed the `display_*` money fields from the `Email*` types and Zod schemas; templates format amounts with the `money` filter. Added `EmailCustomer`, `EmailCustomerGroup` and `EmailNewsletterSubscriber`, which the password reset email's `customer` variable now uses.
diff --git a/docs/developer/customization/email-variables.mdx b/docs/developer/customization/email-variables.mdx
index c5333a327f..05b54fcd88 100644
--- a/docs/developer/customization/email-variables.mdx
+++ b/docs/developer/customization/email-variables.mdx
@@ -38,7 +38,7 @@ These are the emails your customers receive. Every one of their templates receiv
## Objects
-Each object's fields, and the fields of the objects nested in it. Format an amount with the `money` filter (`{{ order.total | money }}`); the `display_*` fields are pre-formatted copies kept for templates customized before 6.0.
+Each object's fields, and the fields of the objects nested in it. Format an amount with the `money` filter (`{{ order.total | money }}`).
### `store`
@@ -47,65 +47,65 @@ 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`, `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`
+- `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`, `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`, `adjustment_total`, `customer_name`, `total_minus_store_credits`
+- `order.discounts`: `id`, `promotion_id`, `name`, `description`, `code`, `amount`
+- `order.fees`: `id`, `label`, `kind`, `line_item_id`, `fulfillment_id`, `amount`
+- `order.items`: `id`, `variant_id`, `seller_id`, `preorder`, `preorder_ships_at`, `quantity`, `currency`, `name`, `slug`, `options_text`, `price`, `total`, `adjustment_total`, `additional_tax_total`, `included_tax_total`, `discount_total`, `pre_tax_amount`, `discounted_amount`, `compare_at_amount`, `url`, `image_url`, `sku`, `amount`
- `order.items.option_values`: `id`, `option_type_id`, `name`, `label`, `position`, `color_code`, `option_type_name`, `option_type_label`, `image_url`
-- `order.fulfillments`: `id`, `number`, `tracking`, `tracking_url`, `pickup_point_data`, `selected_delivery_rate_id`, `unpriced`, `cost`, `display_cost`, `total`, `display_total`, `discount_total`, `display_discount_total`, `additional_tax_total`, `display_additional_tax_total`, `included_tax_total`, `display_included_tax_total`, `tax_total`, `display_tax_total`, `status`, `fulfillment_type`, `fulfilled_at`, `delivered_at`, `items`
+- `order.fulfillments`: `id`, `number`, `tracking`, `tracking_url`, `pickup_point_data`, `selected_delivery_rate_id`, `unpriced`, `cost`, `total`, `discount_total`, `additional_tax_total`, `included_tax_total`, `tax_total`, `status`, `fulfillment_type`, `fulfilled_at`, `delivered_at`, `items`
- `order.fulfillments.deliveries`: `id`, `tracking_number`, `carrier`, `carrier_name`, `service`, `status`, `tracking_url`, `estimated_delivery_at`, `delivered_at`
- `order.fulfillments.delivery_method`: `id`, `name`, `code`, `estimated_transit_business_days_min`, `estimated_transit_business_days_max`, `digital`, `pickup`, `pickup_point`
- `order.fulfillments.stock_location`: `id`, `name`, `address1`, `city`, `zipcode`, `country_code`, `country_name`, `state_code`, `state_text`, `pickup_ready_in_minutes`, `pickup_instructions`
-- `order.fulfillments.delivery_rates`: `id`, `delivery_method_id`, `name`, `selected`, `cost`, `total`, `additional_tax_total`, `included_tax_total`, `tax_total`, `carrier`, `service_level`, `estimated_delivery_date`, `unpriced`, `display_cost`, `display_total`, `display_additional_tax_total`, `display_included_tax_total`, `display_tax_total`
-- `order.payments`: `id`, `payment_method_id`, `response_code`, `number`, `status`, `amount`, `display_amount`, `source_type`, `source_id`, `source`
+- `order.fulfillments.delivery_rates`: `id`, `delivery_method_id`, `name`, `selected`, `cost`, `total`, `additional_tax_total`, `included_tax_total`, `tax_total`, `carrier`, `service_level`, `estimated_delivery_date`, `unpriced`
+- `order.payments`: `id`, `payment_method_id`, `response_code`, `number`, `status`, `amount`, `source_type`, `source_id`, `source`
- `order.payments.payment_method`: `id`, `name`, `description`, `type`, `session_required`, `source_required`
- `order.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.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.gift_card`: `id`, `code`, `status`, `currency`, `amount`, `amount_used`, `amount_authorized`, `amount_remaining`, `display_amount`, `display_amount_used`, `display_amount_remaining`, `expires_at`, `redeemed_at`, `expired`, `active`
+- `order.gift_card`: `id`, `code`, `status`, `currency`, `amount`, `amount_used`, `amount_authorized`, `amount_remaining`, `expires_at`, `redeemed_at`, `expired`, `active`
- `order.market`: `id`, `name`, `currency`, `default_locale`, `tax_inclusive`, `default`, `country_codes`, `country_isos`, `supported_locales`
-- `order.promotion_discounts`: `label`, `display_amount`, `amount`
-- `order.manual_discounts`: `label`, `display_amount`, `amount`
-- `order.fee_lines`: `label`, `display_amount`, `amount`
-- `order.delivery_lines`: `label`, `display_amount`, `amount`
+- `order.promotion_discounts`: `label`, `amount`
+- `order.manual_discounts`: `label`, `amount`
+- `order.fee_lines`: `label`, `amount`
+- `order.delivery_lines`: `label`, `amount`
### `order_group`
-- `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`: `id`, `number`, `email`, `currency`, `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`, `fulfillment_status`, `payment_status`, `completed_at`, `customer_name`, `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`: `id`, `payment_method_id`, `response_code`, `number`, `status`, `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`: `id`, `variant_id`, `seller_id`, `preorder`, `preorder_ships_at`, `quantity`, `currency`, `name`, `slug`, `options_text`, `price`, `total`, `adjustment_total`, `additional_tax_total`, `included_tax_total`, `discount_total`, `pre_tax_amount`, `discounted_amount`, `compare_at_amount`, `url`, `image_url`, `sku`, `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`
-- `order_group.manual_discounts`: `label`, `display_amount`, `amount`
-- `order_group.fee_lines`: `label`, `display_amount`, `amount`
-- `order_group.fulfillment_groups`: `name`, `unpriced`, `cost`, `display_cost`, `seller_names`
-- `order_group.fulfillment_groups.items`: `id`, `url`, `image_url`, `name`, `quantity`, `sku`, `options_text`, `price`, `amount`, `display_price`, `display_amount`
-- `order_group.unfulfilled_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.promotion_discounts`: `label`, `amount`
+- `order_group.manual_discounts`: `label`, `amount`
+- `order_group.fee_lines`: `label`, `amount`
+- `order_group.fulfillment_groups`: `name`, `unpriced`, `cost`, `seller_names`
+- `order_group.fulfillment_groups.items`: `id`, `url`, `image_url`, `name`, `quantity`, `sku`, `options_text`, `price`, `amount`
+- `order_group.unfulfilled_items`: `id`, `variant_id`, `seller_id`, `preorder`, `preorder_ships_at`, `quantity`, `currency`, `name`, `slug`, `options_text`, `price`, `total`, `adjustment_total`, `additional_tax_total`, `included_tax_total`, `discount_total`, `pre_tax_amount`, `discounted_amount`, `compare_at_amount`, `url`, `image_url`, `sku`, `amount`
- `order_group.unfulfilled_items.option_values`: `id`, `option_type_id`, `name`, `label`, `position`, `color_code`, `option_type_name`, `option_type_label`, `image_url`
-- `order_group.delivery_lines`: `label`, `display_amount`, `amount`
+- `order_group.delivery_lines`: `label`, `amount`
### `fulfillment`
-- `fulfillment`: `id`, `number`, `tracking`, `tracking_url`, `pickup_point_data`, `selected_delivery_rate_id`, `unpriced`, `cost`, `display_cost`, `total`, `display_total`, `discount_total`, `display_discount_total`, `additional_tax_total`, `display_additional_tax_total`, `included_tax_total`, `display_included_tax_total`, `tax_total`, `display_tax_total`, `status`, `fulfillment_type`, `fulfilled_at`, `delivered_at`, `items`, `delivery_method_name`
+- `fulfillment`: `id`, `number`, `tracking`, `tracking_url`, `pickup_point_data`, `selected_delivery_rate_id`, `unpriced`, `cost`, `total`, `discount_total`, `additional_tax_total`, `included_tax_total`, `tax_total`, `status`, `fulfillment_type`, `fulfilled_at`, `delivered_at`, `items`, `delivery_method_name`
- `fulfillment.deliveries`: `id`, `tracking_number`, `carrier`, `carrier_name`, `service`, `status`, `tracking_url`, `estimated_delivery_at`, `delivered_at`
- `fulfillment.delivery_method`: `id`, `name`, `code`, `estimated_transit_business_days_min`, `estimated_transit_business_days_max`, `digital`, `pickup`, `pickup_point`
- `fulfillment.stock_location`: `id`, `name`, `address1`, `city`, `zipcode`, `country_code`, `country_name`, `state_code`, `state_text`, `pickup_ready_in_minutes`, `pickup_instructions`
-- `fulfillment.delivery_rates`: `id`, `delivery_method_id`, `name`, `selected`, `cost`, `total`, `additional_tax_total`, `included_tax_total`, `tax_total`, `carrier`, `service_level`, `estimated_delivery_date`, `unpriced`, `display_cost`, `display_total`, `display_additional_tax_total`, `display_included_tax_total`, `display_tax_total`
+- `fulfillment.delivery_rates`: `id`, `delivery_method_id`, `name`, `selected`, `cost`, `total`, `additional_tax_total`, `included_tax_total`, `tax_total`, `carrier`, `service_level`, `estimated_delivery_date`, `unpriced`
- `fulfillment.delivery_rates.freight_summary`: `total_units`, `total_cartons`, `total_pallets`, `total_volume`, `total_weight`, `complete`
- `fulfillment.delivery_rates.delivery_method`: `id`, `name`, `code`, `estimated_transit_business_days_min`, `estimated_transit_business_days_max`, `digital`, `pickup`, `pickup_point`
-- `fulfillment.manifest_items`: `id`, `url`, `image_url`, `name`, `quantity`, `sku`, `options_text`, `price`, `amount`, `display_price`, `display_amount`
+- `fulfillment.manifest_items`: `id`, `url`, `image_url`, `name`, `quantity`, `sku`, `options_text`, `price`, `amount`
### `return`
-- `return`: `id`, `number`, `status`, `order_id`, `reason_id`, `refund_total`, `display_refund_total`, `approved_at`, `received_at`, `refunded_at`, `canceled_at`, `refunded_total`, `display_refunded_total`
-- `return.returned_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`
+- `return`: `id`, `number`, `status`, `order_id`, `reason_id`, `refund_total`, `approved_at`, `received_at`, `refunded_at`, `canceled_at`, `refunded_total`
+- `return.returned_items`: `id`, `variant_id`, `seller_id`, `preorder`, `preorder_ships_at`, `quantity`, `currency`, `name`, `slug`, `options_text`, `price`, `total`, `adjustment_total`, `additional_tax_total`, `included_tax_total`, `discount_total`, `pre_tax_amount`, `discounted_amount`, `compare_at_amount`, `url`, `image_url`, `sku`, `amount`
- `return.returned_items.option_values`: `id`, `option_type_id`, `name`, `label`, `position`, `color_code`, `option_type_name`, `option_type_label`, `image_url`
### `customer`
-- `customer`: `id`, `email`, `first_name`, `last_name`, `phone`, `accepts_email_marketing`, `email_marketing_consent_updated_at`, `full_name`, `available_store_credit_total`, `display_available_store_credit_total`
+- `customer`: `id`, `email`, `first_name`, `last_name`, `phone`, `accepts_email_marketing`, `email_marketing_consent_updated_at`, `full_name`, `available_store_credit_total`
- `customer.addresses`: `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`
- `customer.default_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`
- `customer.default_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`
diff --git a/docs/developer/customization/emails.mdx b/docs/developer/customization/emails.mdx
index 30957f431f..f34ec51bbb 100644
--- a/docs/developer/customization/emails.mdx
+++ b/docs/developer/customization/emails.mdx
@@ -78,7 +78,7 @@ Besides [Liquid's standard filters](https://shopify.github.io/liquid/filters/abs
| `t` | `{{ 'order_mailer.confirm_email.dear_customer' \| t: name: order.customer_name }}` | A Spree translation, with its placeholders filled in |
| `raw` | `{{ product.description_html \| raw }}` | Prints the value without escaping. See below |
-Amounts arrive as decimal strings (`total`, `amount`, `price`), so format them with `money`: `{{ order.total | money }}`. It writes the amount in the email's currency and in the customer's language, the same way for every template. The `display_*` fields (`display_total`, `display_amount`) still arrive, so templates customized before 6.0 keep working, but the default templates no longer use them and new templates should not either.
+Amounts arrive as decimal strings (`total`, `amount`, `price`), so format them with `money`: `{{ order.total | money }}`. It writes the amount in the email's currency and in the customer's language, the same way for every template.
## Escaping
diff --git a/docs/developer/upgrades/5.6-to-6.0.mdx b/docs/developer/upgrades/5.6-to-6.0.mdx
index 5ea5a43c9d..ae3c375189 100644
--- a/docs/developer/upgrades/5.6-to-6.0.mdx
+++ b/docs/developer/upgrades/5.6-to-6.0.mdx
@@ -912,8 +912,7 @@ Other changes that come with it:
- **Money on the API is written to each currency's decimals.** Every amount in the Store, Admin and Seller APIs, and so in webhook payloads and email variables, is a decimal string with exactly its currency's decimal places: `"10.00"` (was `"10.0"`), `"1000"` in yen (was `"1000.0"`), `"1.500"` in dinar. Unit prices keep up to four decimals. Fields that were JSON numbers are now strings: `cart.order_minimum` and `order_minimum_shortfall`, the product filter price range `min`/`max`, report money metrics and percentages, and the store's `default_minimum_payout_amount` and `default_commission_tax_rate`. Clients comparing these strings, or parsing them as numbers, should switch to exact decimal arithmetic; the SDKs export `sumMoney`, `subtractMoney`, `multiplyMoney`, `compareMoney` and `isZeroMoney`.
- **Admin and Seller writes refuse JSON numbers for money.** Amounts and rates, including those inside `preferences`, must be canonical decimal strings (`"19.99"`). A number, a localized or grouped string, or more decimals than the field holds is answered with `422` and `invalid_money_format`, naming the field.
- **Amounts may not carry more decimals than they can keep.** Now that the columns hold four decimals, the database no longer rounds away a fraction of a cent, so a payment, refund, store credit, gift card, fee or discount with more decimals than its currency has (`10.0049` dollars) fails validation with `too_many_decimals`. Unit prices and cost prices allow four, tax rates five decimals of the fraction (`rate_percent` `"7.125"`, not `"7.1255"`), and price list percentages three. Round in your own code before saving. A manual order discount's `value` and a commission rate's `value` are read as strictly as other money fields.
-- **The Admin and Seller APIs no longer return `display_*` money fields.** Responses carry the amount (`"29.99"`) with its currency, and the client formats it in the reader's own language. Before 6.0 the server formatted a copy in the request's language, which could disagree with the editable amount beside it. Format with `Intl.NumberFormat` or your platform's equivalent. The Store API, webhook payloads and email templates keep their `display_*` fields, and labels such as `display_name` are unchanged.
-- **Email templates format money with the `money` filter.** The default templates print `{{ order.total | money }}` instead of `{{ order.display_total }}`; the output is the same. Email data gains the raw amounts the templates needed (`total_minus_store_credits`, a line item's `amount`, a parcel's `cost` and `unpriced`, a return's `refunded_total`). The `display_*` fields are still sent, so a template customized before 6.0 keeps working; merchants who customized one see the "updated by Spree" notice in the email editor.
+- **The Admin and Seller APIs no longer return `display_*` money fields.** Responses carry the amount (`"29.99"`) with its currency, and the client formats it in the reader's own language. Before 6.0 the server formatted a copy in the request's language, which could disagree with the editable amount beside it. Format with `Intl.NumberFormat` or your platform's equivalent. The Store API and webhook payloads keep their `display_*` fields, and labels such as `display_name` are unchanged.
- **Money preferences have their own type.** Calculator, rule and store preferences holding an amount (`amount`, `first_item`, `minimal_amount`, `amount_min`, `min_amount`, `default_minimum_payout_amount` and the like) are declared `:money` instead of `:decimal`, report `money` in `preference_schema`, and are written with the decimals of the calculator's currency (`"12.50"` rather than `"12.5"`). Declare your own extensions' amounts with `:money` so the dashboard shows their currency. A `:decimal` or `:money` preference now refuses text such as `"1,599.99"` instead of reading it as 1. Money preferences are checked by their type on write: a value that is not a decimal string, or has more decimals than its currency, is refused with `invalid_preferences` and a pointer to the field (`/calculator/preferences/amount`), rather than `invalid_money_format`.
- **Rates are decimal strings, and tax rates are renamed.** Rates and percentages read and write as strings without trailing zeros. A tax rate's `amount` (a fraction) is now `rate`, and `amount_percentage` is `rate_percent`; `Spree::TaxRate#amount_percentage` keeps working with a warning until 6.1.
- **`amount_in_cents` and `compare_at_amount_in_cents` are removed** from prices and price history. Read `amount`, and each currency's `decimal_places` (new on `GET /api/v3/store/currencies`) if you need minor units.
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailAmountLine.ts b/packages/admin-sdk/src/types/generated/emails/EmailAmountLine.ts
index a1124af888..4ac7cb3a97 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailAmountLine.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailAmountLine.ts
@@ -1,10 +1,9 @@
-// Typelizer digest d469ceee2e70ce2813c8afdab7ebe727
+// Typelizer digest a3b49683f949c080c0dc0c3969a880ac
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
interface EmailAmountLine {
label: string | null;
- display_amount: string;
amount: string;
}
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailAppliedPromotion.ts b/packages/admin-sdk/src/types/generated/emails/EmailAppliedPromotion.ts
index 684c83dee9..c4502f58c1 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailAppliedPromotion.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailAppliedPromotion.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 3066d72bad701be86c3f22791eec97a8
+// Typelizer digest 42c3ced435ef05381c3ce7c74c2caa4f
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
@@ -9,7 +9,6 @@ interface EmailAppliedPromotion {
description: string | null;
code: string | null;
amount: string | null;
- display_amount: string | null;
}
export default EmailAppliedPromotion;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailCustomer.ts b/packages/admin-sdk/src/types/generated/emails/EmailCustomer.ts
new file mode 100644
index 0000000000..fc59b5ea09
--- /dev/null
+++ b/packages/admin-sdk/src/types/generated/emails/EmailCustomer.ts
@@ -0,0 +1,23 @@
+// Typelizer digest d0a885a9fb1bfb9dcda90ef2a927a567
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+import type {EmailAddress, EmailNewsletterSubscriber, EmailCustomerGroup} from '.'
+
+interface EmailCustomer {
+ id: string;
+ email: string;
+ first_name: string | null;
+ last_name: string | null;
+ phone: string | null;
+ accepts_email_marketing: boolean;
+ email_marketing_consent_updated_at: string | null;
+ full_name: string;
+ available_store_credit_total: string;
+ addresses: Array<EmailAddress>;
+ default_billing_address: EmailAddress | null;
+ default_shipping_address: EmailAddress | null;
+ newsletter_subscriber: EmailNewsletterSubscriber | null;
+ customer_groups: Array<EmailCustomerGroup>;
+}
+
+export default EmailCustomer;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailCustomerGroup.ts b/packages/admin-sdk/src/types/generated/emails/EmailCustomerGroup.ts
new file mode 100644
index 0000000000..13a2e667d9
--- /dev/null
+++ b/packages/admin-sdk/src/types/generated/emails/EmailCustomerGroup.ts
@@ -0,0 +1,10 @@
+// Typelizer digest fb7c4da6cf51e0fc8efd28986ef19ca7
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+interface EmailCustomerGroup {
+ id: string;
+ name: string;
+}
+
+export default EmailCustomerGroup;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailDeliveryRate.ts b/packages/admin-sdk/src/types/generated/emails/EmailDeliveryRate.ts
index 22afba405a..f96582450b 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailDeliveryRate.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailDeliveryRate.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 3da8add8702cca5913d5c8b30c86079a
+// Typelizer digest 2cdd020f8214ef2a65954aecc044c3bf
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {EmailFreightSummary, EmailDeliveryMethod} from '.'
@@ -18,11 +18,6 @@ interface EmailDeliveryRate {
estimated_delivery_date: string | null;
unpriced: boolean;
freight_summary: EmailFreightSummary | null;
- display_cost: string | null;
- display_total: string | null;
- display_additional_tax_total: string | null;
- display_included_tax_total: string | null;
- display_tax_total: string | null;
delivery_method: EmailDeliveryMethod;
}
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailFee.ts b/packages/admin-sdk/src/types/generated/emails/EmailFee.ts
index aa36847a88..cb5ec87072 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailFee.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailFee.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 59d674d9033ef8b43a0b4a4d344d4edd
+// Typelizer digest af895b5f438769429ae6f1a0791d2114
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {FeeKind} from '.'
@@ -11,7 +11,6 @@ interface EmailFee {
line_item_id: string | null;
fulfillment_id: string | null;
amount: string | null;
- display_amount: string | null;
}
export default EmailFee;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailFulfillment.ts b/packages/admin-sdk/src/types/generated/emails/EmailFulfillment.ts
index e31aaf2cb0..ac23f740b9 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailFulfillment.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailFulfillment.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 2db3e4715367ef7be80f5e320974fd6d
+// Typelizer digest 4db1b59ddeebd9e61a6a130c462d4122
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {EmailDelivery, EmailDeliveryMethod, EmailStockLocation, EmailDeliveryRate, EmailParcelItem, FulfillmentStatus} from '.'
@@ -12,17 +12,11 @@ interface EmailFulfillment {
selected_delivery_rate_id: string | null;
unpriced: boolean;
cost: string | null;
- display_cost: string | null;
total: string | null;
- display_total: string | null;
discount_total: string | null;
- display_discount_total: string | null;
additional_tax_total: string | null;
- display_additional_tax_total: string | null;
included_tax_total: string | null;
- display_included_tax_total: string | null;
tax_total: string | null;
- display_tax_total: string | null;
status: FulfillmentStatus;
fulfillment_type: 'shipping' | 'digital' | 'pickup' | 'pickup_point';
fulfilled_at: string | null;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailFulfillmentGroup.ts b/packages/admin-sdk/src/types/generated/emails/EmailFulfillmentGroup.ts
index 9784a1d76e..261e534334 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailFulfillmentGroup.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailFulfillmentGroup.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 3489d6d3770fd6af28ae0fa2c73eba12
+// Typelizer digest 132c6e130458251e515142281a12dcfd
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {EmailParcelItem} from '.'
@@ -7,7 +7,6 @@ interface EmailFulfillmentGroup {
name: string | null;
unpriced: boolean;
cost: string;
- display_cost: string;
seller_names: Array<string>;
items: Array<EmailParcelItem>;
}
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailGiftCard.ts b/packages/admin-sdk/src/types/generated/emails/EmailGiftCard.ts
index dbd84e7cfb..00179fa546 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailGiftCard.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailGiftCard.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 3957a94f3e00c16ce7aa1ad43ca53299
+// Typelizer digest 10b7f995897f5c00a9adb3e8584163b9
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {GiftCardStatus, CurrencyCode} from '.'
@@ -12,9 +12,6 @@ interface EmailGiftCard {
amount_used: string | null;
amount_authorized: string | null;
amount_remaining: string | null;
- display_amount: string | null;
- display_amount_used: string | null;
- display_amount_remaining: string | null;
expires_at: string | null;
redeemed_at: string | null;
expired: boolean;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailLineItem.ts b/packages/admin-sdk/src/types/generated/emails/EmailLineItem.ts
index e34aba42e3..00635a356e 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailLineItem.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailLineItem.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 18dfb65fa64a909cc0e7944e74c7ae2d
+// Typelizer digest b7be38df7dcedd69294d779533aa4d0f
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {EmailOptionValue, CurrencyCode} from '.'
@@ -15,29 +15,19 @@ interface EmailLineItem {
slug: string;
options_text: string;
price: string | null;
- display_price: string | null;
total: string | null;
- display_total: string | null;
adjustment_total: string | null;
- display_adjustment_total: string | null;
additional_tax_total: string | null;
- display_additional_tax_total: string | null;
included_tax_total: string | null;
- display_included_tax_total: string | null;
discount_total: string | null;
- display_discount_total: string | null;
pre_tax_amount: string | null;
- display_pre_tax_amount: string | null;
discounted_amount: string | null;
- display_discounted_amount: string | null;
- display_compare_at_amount: string | null;
compare_at_amount: string | null;
option_values: Array<EmailOptionValue>;
url: string | null;
image_url: string | null;
sku: string | null;
amount: string;
- display_amount: string;
}
export default EmailLineItem;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailNewsletterSubscriber.ts b/packages/admin-sdk/src/types/generated/emails/EmailNewsletterSubscriber.ts
new file mode 100644
index 0000000000..eeb388caf5
--- /dev/null
+++ b/packages/admin-sdk/src/types/generated/emails/EmailNewsletterSubscriber.ts
@@ -0,0 +1,15 @@
+// Typelizer digest 79c81ba5e879fd15070d8cf79b6242cb
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+interface EmailNewsletterSubscriber {
+ id: string;
+ email: string;
+ created_at: string;
+ updated_at: string;
+ verified: boolean;
+ verified_at: string | null;
+ customer_id: string | null;
+}
+
+export default EmailNewsletterSubscriber;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts b/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts
index 430e346486..108d13e947 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailOrder.ts
@@ -1,4 +1,4 @@
-// Typelizer digest a2f82c5fe2aeae6f78bacaeee8be666f
+// Typelizer digest c0cc8d5f705c4953cc3ebbb22c173998
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {EmailPayment, EmailAppliedPromotion, EmailFee, EmailLineItem, EmailFulfillment, EmailAddress, EmailGiftCard, EmailMarket, EmailAmountLine, CurrencyCode} from '.'
@@ -26,31 +26,19 @@ interface EmailOrder {
payment_status: 'none' | 'authorized' | 'partially_paid' | 'paid' | 'partially_refunded' | 'refunded' | 'overcharged' | 'voided' | null;
completed_at: 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>;
adjustment_total: string | null;
- display_adjustment_total: string | null;
discounts: Array<EmailAppliedPromotion>;
fees: Array<EmailFee>;
items: Array<EmailLineItem>;
@@ -61,7 +49,6 @@ interface EmailOrder {
market: EmailMarket | null;
customer_name: string;
total_minus_store_credits: string;
- display_total_minus_store_credits: string;
promotion_discounts: Array<EmailAmountLine>;
manual_discounts: Array<EmailAmountLine>;
fee_lines: Array<EmailAmountLine>;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailOrderGroup.ts b/packages/admin-sdk/src/types/generated/emails/EmailOrderGroup.ts
index 491b1c29ee..98fb9da91f 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailOrderGroup.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailOrderGroup.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 993251fbcbb39ee47da3259734bb4c7d
+// Typelizer digest 458576791161ac4a1dbc9eaf2c5d3fbf
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {EmailPayment, EmailAddress, EmailLineItem, EmailAmountLine, EmailFulfillmentGroup, CurrencyCode} from '.'
@@ -9,27 +9,16 @@ interface EmailOrderGroup {
email: string | null;
currency: CurrencyCode;
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;
@@ -39,7 +28,6 @@ interface EmailOrderGroup {
shipping_address: EmailAddress | null;
customer_name: string;
total_minus_store_credits: string;
- display_total_minus_store_credits: string;
items: Array<EmailLineItem>;
promotion_discounts: Array<EmailAmountLine>;
manual_discounts: Array<EmailAmountLine>;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailParcelItem.ts b/packages/admin-sdk/src/types/generated/emails/EmailParcelItem.ts
index 8d162a5f8c..cd2e63f67b 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailParcelItem.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailParcelItem.ts
@@ -1,4 +1,4 @@
-// Typelizer digest f2645f463e6187c2ee90f8101f8a1bcf
+// Typelizer digest 269755567490468aadc8810ca38e113f
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
@@ -12,8 +12,6 @@ interface EmailParcelItem {
options_text: string | null;
price: string;
amount: string;
- display_price: string;
- display_amount: string;
}
export default EmailParcelItem;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailPayment.ts b/packages/admin-sdk/src/types/generated/emails/EmailPayment.ts
index 9db882077f..b3330f76ce 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailPayment.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailPayment.ts
@@ -1,4 +1,4 @@
-// Typelizer digest 6bedde0fdf4a3bc87a4929600ec3e548
+// Typelizer digest e015c656ea88ba4749d7b941afbe6560
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {EmailPaymentMethod, PaymentStatus} from '.'
@@ -10,7 +10,6 @@ interface EmailPayment {
number: string;
status: PaymentStatus;
amount: string | null;
- display_amount: string | null;
source_type: 'credit_card' | 'store_credit' | 'payment_source' | null;
source_id: string | null;
source: Record<string, unknown> | null;
diff --git a/packages/admin-sdk/src/types/generated/emails/EmailReturn.ts b/packages/admin-sdk/src/types/generated/emails/EmailReturn.ts
index 5087a0a5f0..9bc5790e44 100644
--- a/packages/admin-sdk/src/types/generated/emails/EmailReturn.ts
+++ b/packages/admin-sdk/src/types/generated/emails/EmailReturn.ts
@@ -1,4 +1,4 @@
-// Typelizer digest e601a1b03e815505bd403d7939648887
+// Typelizer digest 19889738c266c62ade981ecd0a2aa645
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {EmailLineItem, ReturnStatus} from '.'
@@ -10,15 +10,12 @@ interface EmailReturn {
order_id: string | null;
reason_id: string | null;
refund_total: string | null;
- display_refund_total: string | null;
refund_tax_total: string | null;
- display_refund_tax_total: string | null;
approved_at: string | null;
received_at: string | null;
refunded_at: string | null;
canceled_at: string | null;
refunded_total: string;
- display_refunded_total: string;
returned_items: Array<EmailLineItem>;
}
diff --git a/packages/admin-sdk/src/types/generated/emails/index.ts b/packages/admin-sdk/src/types/generated/emails/index.ts
index 4fb75b92c9..4735676f37 100644
--- a/packages/admin-sdk/src/types/generated/emails/index.ts
+++ b/packages/admin-sdk/src/types/generated/emails/index.ts
@@ -1,10 +1,12 @@
-// Typelizer digest dccf27f753c2c7480ceedaca57e17a09
+// Typelizer digest c433592c8f03b732b455cae3f5c21359
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
export type { CountryCode, CurrencyCode, FeeKind, FulfillmentStatus, GiftCardStatus, PaymentStatus, ReturnStatus } from './Enums'
export type { default as EmailAddress } from './EmailAddress'
export type { default as EmailAmountLine } from './EmailAmountLine'
export type { default as EmailAppliedPromotion } from './EmailAppliedPromotion'
+export type { default as EmailCustomerGroup } from './EmailCustomerGroup'
+export type { default as EmailCustomer } from './EmailCustomer'
export type { default as EmailDeliveryMethod } from './EmailDeliveryMethod'
export type { default as EmailDeliveryRate } from './EmailDeliveryRate'
export type { default as EmailDelivery } from './EmailDelivery'
@@ -15,6 +17,7 @@ export type { default as EmailFulfillment } from './EmailFulfillment'
export type { default as EmailGiftCard } from './EmailGiftCard'
export type { default as EmailLineItem } from './EmailLineItem'
export type { default as EmailMarket } from './EmailMarket'
+export type { default as EmailNewsletterSubscriber } from './EmailNewsletterSubscriber'
export type { default as EmailOptionValue } from './EmailOptionValue'
export type { default as EmailOrderGroup } from './EmailOrderGroup'
export type { default as EmailOrder } from './EmailOrder'
diff --git a/packages/admin-sdk/src/types/index.ts b/packages/admin-sdk/src/types/index.ts
index 4f7adb59b3..1c865d2bbd 100644
--- a/packages/admin-sdk/src/types/index.ts
+++ b/packages/admin-sdk/src/types/index.ts
@@ -88,6 +88,8 @@ export type { default as Export } from './generated/Export'
export type { default as EmailAddress } from './generated/emails/EmailAddress'
export type { default as EmailAmountLine } from './generated/emails/EmailAmountLine'
export type { default as EmailAppliedPromotion } from './generated/emails/EmailAppliedPromotion'
+export type { default as EmailCustomer } from './generated/emails/EmailCustomer'
+export type { default as EmailCustomerGroup } from './generated/emails/EmailCustomerGroup'
export type { default as EmailDelivery } from './generated/emails/EmailDelivery'
export type { default as EmailDeliveryMethod } from './generated/emails/EmailDeliveryMethod'
export type { default as EmailDeliveryRate } from './generated/emails/EmailDeliveryRate'
@@ -98,6 +100,7 @@ export type { default as EmailFulfillmentGroup } from './generated/emails/EmailF
export type { default as EmailGiftCard } from './generated/emails/EmailGiftCard'
export type { default as EmailLineItem } from './generated/emails/EmailLineItem'
export type { default as EmailMarket } from './generated/emails/EmailMarket'
+export type { default as EmailNewsletterSubscriber } from './generated/emails/EmailNewsletterSubscriber'
export type { default as EmailOptionValue } from './generated/emails/EmailOptionValue'
export type { default as EmailOrder } from './generated/emails/EmailOrder'
export type { default as EmailOrderGroup } from './generated/emails/EmailOrderGroup'
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailAmountLine.ts b/packages/admin-sdk/src/zod/generated/emails/EmailAmountLine.ts
index b284164c9a..8de8f78757 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailAmountLine.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailAmountLine.ts
@@ -3,7 +3,6 @@ import { z } from 'zod';
export const EmailAmountLineSchema = z.object({
label: z.string().nullable(),
- display_amount: z.string(),
amount: z.string(),
});
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailAppliedPromotion.ts b/packages/admin-sdk/src/zod/generated/emails/EmailAppliedPromotion.ts
index 72c32d41e6..620134a325 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailAppliedPromotion.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailAppliedPromotion.ts
@@ -8,7 +8,6 @@ export const EmailAppliedPromotionSchema = z.object({
description: z.string().nullable(),
code: z.string().nullable(),
amount: z.string().nullable(),
- display_amount: z.string().nullable(),
});
export type EmailAppliedPromotion = z.infer<typeof EmailAppliedPromotionSchema>;
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailCustomer.ts b/packages/admin-sdk/src/zod/generated/emails/EmailCustomer.ts
new file mode 100644
index 0000000000..782ab04575
--- /dev/null
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailCustomer.ts
@@ -0,0 +1,24 @@
+// This file is auto-generated. Do not edit directly.
+import { z } from 'zod';
+import { EmailAddressSchema } from './EmailAddress';
+import { EmailCustomerGroupSchema } from './EmailCustomerGroup';
+import { EmailNewsletterSubscriberSchema } from './EmailNewsletterSubscriber';
+
+export const EmailCustomerSchema = z.object({
+ id: z.string(),
+ email: z.string(),
+ first_name: z.string().nullable(),
+ last_name: z.string().nullable(),
+ phone: z.string().nullable(),
+ accepts_email_marketing: z.boolean(),
+ email_marketing_consent_updated_at: z.string().nullable(),
+ full_name: z.string(),
+ available_store_credit_total: z.string(),
+ addresses: z.array(EmailAddressSchema),
+ default_billing_address: EmailAddressSchema.nullable(),
+ default_shipping_address: EmailAddressSchema.nullable(),
+ newsletter_subscriber: EmailNewsletterSubscriberSchema.nullable(),
+ customer_groups: z.array(EmailCustomerGroupSchema),
+});
+
+export type EmailCustomer = z.infer<typeof EmailCustomerSchema>;
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailCustomerGroup.ts b/packages/admin-sdk/src/zod/generated/emails/EmailCustomerGroup.ts
new file mode 100644
index 0000000000..f21e316f17
--- /dev/null
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailCustomerGroup.ts
@@ -0,0 +1,9 @@
+// This file is auto-generated. Do not edit directly.
+import { z } from 'zod';
+
+export const EmailCustomerGroupSchema = z.object({
+ id: z.string(),
+ name: z.string(),
+});
+
+export type EmailCustomerGroup = z.infer<typeof EmailCustomerGroupSchema>;
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailDeliveryRate.ts b/packages/admin-sdk/src/zod/generated/emails/EmailDeliveryRate.ts
index 527134f792..a63eaa41c3 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailDeliveryRate.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailDeliveryRate.ts
@@ -18,11 +18,6 @@ export const EmailDeliveryRateSchema = z.object({
estimated_delivery_date: z.string().nullable(),
unpriced: z.boolean(),
freight_summary: EmailFreightSummarySchema.nullable(),
- display_cost: z.string().nullable(),
- display_total: z.string().nullable(),
- display_additional_tax_total: z.string().nullable(),
- display_included_tax_total: z.string().nullable(),
- display_tax_total: z.string().nullable(),
delivery_method: EmailDeliveryMethodSchema,
});
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailFee.ts b/packages/admin-sdk/src/zod/generated/emails/EmailFee.ts
index 460a6c4686..20a4cb611d 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailFee.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailFee.ts
@@ -8,7 +8,6 @@ export const EmailFeeSchema = z.object({
line_item_id: z.string().nullable(),
fulfillment_id: z.string().nullable(),
amount: z.string().nullable(),
- display_amount: z.string().nullable(),
});
export type EmailFee = z.infer<typeof EmailFeeSchema>;
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailFulfillment.ts b/packages/admin-sdk/src/zod/generated/emails/EmailFulfillment.ts
index 46a320da30..2c385fa541 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailFulfillment.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailFulfillment.ts
@@ -15,17 +15,11 @@ export const EmailFulfillmentSchema = z.object({
selected_delivery_rate_id: z.string().nullable(),
unpriced: z.boolean(),
cost: z.string().nullable(),
- display_cost: z.string().nullable(),
total: z.string().nullable(),
- display_total: z.string().nullable(),
discount_total: z.string().nullable(),
- display_discount_total: z.string().nullable(),
additional_tax_total: z.string().nullable(),
- display_additional_tax_total: z.string().nullable(),
included_tax_total: z.string().nullable(),
- display_included_tax_total: z.string().nullable(),
tax_total: z.string().nullable(),
- display_tax_total: z.string().nullable(),
status: z.string(),
fulfillment_type: z.string(),
fulfilled_at: z.string().nullable(),
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailFulfillmentGroup.ts b/packages/admin-sdk/src/zod/generated/emails/EmailFulfillmentGroup.ts
index ca2c298b74..4b8171b521 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailFulfillmentGroup.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailFulfillmentGroup.ts
@@ -6,7 +6,6 @@ export const EmailFulfillmentGroupSchema = z.object({
name: z.string().nullable(),
unpriced: z.boolean(),
cost: z.string(),
- display_cost: z.string(),
seller_names: z.array(z.string()),
items: z.array(EmailParcelItemSchema),
});
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailGiftCard.ts b/packages/admin-sdk/src/zod/generated/emails/EmailGiftCard.ts
index cf35b686e5..58af3d9b3f 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailGiftCard.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailGiftCard.ts
@@ -10,9 +10,6 @@ export const EmailGiftCardSchema = z.object({
amount_used: z.string().nullable(),
amount_authorized: z.string().nullable(),
amount_remaining: z.string().nullable(),
- display_amount: z.string().nullable(),
- display_amount_used: z.string().nullable(),
- display_amount_remaining: z.string().nullable(),
expires_at: z.string().nullable(),
redeemed_at: z.string().nullable(),
expired: z.boolean(),
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailLineItem.ts b/packages/admin-sdk/src/zod/generated/emails/EmailLineItem.ts
index 9ed710f96a..4164fae6dd 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailLineItem.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailLineItem.ts
@@ -14,29 +14,19 @@ export const EmailLineItemSchema = z.object({
slug: z.string(),
options_text: z.string(),
price: z.string().nullable(),
- display_price: z.string().nullable(),
total: z.string().nullable(),
- display_total: z.string().nullable(),
adjustment_total: z.string().nullable(),
- display_adjustment_total: z.string().nullable(),
additional_tax_total: z.string().nullable(),
- display_additional_tax_total: z.string().nullable(),
included_tax_total: z.string().nullable(),
- display_included_tax_total: z.string().nullable(),
discount_total: z.string().nullable(),
- display_discount_total: z.string().nullable(),
pre_tax_amount: z.string().nullable(),
- display_pre_tax_amount: z.string().nullable(),
discounted_amount: z.string().nullable(),
- display_discounted_amount: z.string().nullable(),
- display_compare_at_amount: z.string().nullable(),
compare_at_amount: z.string().nullable(),
option_values: z.array(EmailOptionValueSchema),
url: z.string().nullable(),
image_url: z.string().nullable(),
sku: z.string().nullable(),
amount: z.string(),
- display_amount: z.string(),
});
export type EmailLineItem = z.infer<typeof EmailLineItemSchema>;
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailNewsletterSubscriber.ts b/packages/admin-sdk/src/zod/generated/emails/EmailNewsletterSubscriber.ts
new file mode 100644
index 0000000000..606a5eabaf
--- /dev/null
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailNewsletterSubscriber.ts
@@ -0,0 +1,14 @@
+// This file is auto-generated. Do not edit directly.
+import { z } from 'zod';
+
+export const EmailNewsletterSubscriberSchema = z.object({
+ id: z.string(),
+ email: z.string(),
+ created_at: z.string(),
+ updated_at: z.string(),
+ verified: z.boolean(),
+ verified_at: z.string().nullable(),
+ customer_id: z.string().nullable(),
+});
+
+export type EmailNewsletterSubscriber = z.infer<typeof EmailNewsletterSubscriberSchema>;
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailOrder.ts b/packages/admin-sdk/src/zod/generated/emails/EmailOrder.ts
index adfe40fead..97a19a9357 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailOrder.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailOrder.ts
@@ -33,31 +33,19 @@ export const EmailOrderSchema = z.object({
payment_status: z.string().nullable(),
completed_at: 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),
adjustment_total: z.string().nullable(),
- display_adjustment_total: z.string().nullable(),
discounts: z.array(EmailAppliedPromotionSchema),
fees: z.array(EmailFeeSchema),
items: z.array(EmailLineItemSchema),
@@ -68,7 +56,6 @@ export const EmailOrderSchema = z.object({
market: EmailMarketSchema.nullable(),
customer_name: z.string(),
total_minus_store_credits: z.string(),
- display_total_minus_store_credits: z.string(),
promotion_discounts: z.array(EmailAmountLineSchema),
manual_discounts: z.array(EmailAmountLineSchema),
fee_lines: z.array(EmailAmountLineSchema),
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailOrderGroup.ts b/packages/admin-sdk/src/zod/generated/emails/EmailOrderGroup.ts
index 59b4d81ac7..ff4ec7b3a9 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailOrderGroup.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailOrderGroup.ts
@@ -12,27 +12,16 @@ export const EmailOrderGroupSchema = z.object({
email: z.string().nullable(),
currency: z.string(),
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(),
@@ -42,7 +31,6 @@ export const EmailOrderGroupSchema = z.object({
shipping_address: EmailAddressSchema.nullable(),
customer_name: z.string(),
total_minus_store_credits: z.string(),
- display_total_minus_store_credits: z.string(),
items: z.array(EmailLineItemSchema),
promotion_discounts: z.array(EmailAmountLineSchema),
manual_discounts: z.array(EmailAmountLineSchema),
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailParcelItem.ts b/packages/admin-sdk/src/zod/generated/emails/EmailParcelItem.ts
index d7d87cb9a8..f0a26388ec 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailParcelItem.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailParcelItem.ts
@@ -11,8 +11,6 @@ export const EmailParcelItemSchema = z.object({
options_text: z.string().nullable(),
price: z.string(),
amount: z.string(),
- display_price: z.string(),
- display_amount: z.string(),
});
export type EmailParcelItem = z.infer<typeof EmailParcelItemSchema>;
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailPayment.ts b/packages/admin-sdk/src/zod/generated/emails/EmailPayment.ts
index eaa0742ed2..546a0278e6 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailPayment.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailPayment.ts
@@ -9,7 +9,6 @@ export const EmailPaymentSchema = z.object({
number: z.string(),
status: z.string(),
amount: z.string().nullable(),
- display_amount: z.string().nullable(),
source_type: z.string().nullable(),
source_id: z.string().nullable(),
source: z.record(z.string(), z.unknown()).nullable(),
diff --git a/packages/admin-sdk/src/zod/generated/emails/EmailReturn.ts b/packages/admin-sdk/src/zod/generated/emails/EmailReturn.ts
index 568ca6359a..431370dcc3 100644
--- a/packages/admin-sdk/src/zod/generated/emails/EmailReturn.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/EmailReturn.ts
@@ -9,15 +9,12 @@ export const EmailReturnSchema = z.object({
order_id: z.string().nullable(),
reason_id: z.string().nullable(),
refund_total: z.string().nullable(),
- display_refund_total: z.string().nullable(),
refund_tax_total: z.string().nullable(),
- display_refund_tax_total: z.string().nullable(),
approved_at: z.string().nullable(),
received_at: z.string().nullable(),
refunded_at: z.string().nullable(),
canceled_at: z.string().nullable(),
refunded_total: z.string(),
- display_refunded_total: z.string(),
returned_items: z.array(EmailLineItemSchema),
});
diff --git a/packages/admin-sdk/src/zod/generated/emails/index.ts b/packages/admin-sdk/src/zod/generated/emails/index.ts
index 25a1b24dd5..bb033454ca 100644
--- a/packages/admin-sdk/src/zod/generated/emails/index.ts
+++ b/packages/admin-sdk/src/zod/generated/emails/index.ts
@@ -2,6 +2,8 @@
export { EmailAddressSchema, type EmailAddress } from './EmailAddress';
export { EmailAmountLineSchema, type EmailAmountLine } from './EmailAmountLine';
export { EmailAppliedPromotionSchema, type EmailAppliedPromotion } from './EmailAppliedPromotion';
+export { EmailCustomerSchema, type EmailCustomer } from './EmailCustomer';
+export { EmailCustomerGroupSchema, type EmailCustomerGroup } from './EmailCustomerGroup';
export { EmailDeliverySchema, type EmailDelivery } from './EmailDelivery';
export { EmailDeliveryMethodSchema, type EmailDeliveryMethod } from './EmailDeliveryMethod';
export { EmailDeliveryRateSchema, type EmailDeliveryRate } from './EmailDeliveryRate';
@@ -12,6 +14,7 @@ export { EmailFulfillmentGroupSchema, type EmailFulfillmentGroup } from './Email
export { EmailGiftCardSchema, type EmailGiftCard } from './EmailGiftCard';
export { EmailLineItemSchema, type EmailLineItem } from './EmailLineItem';
export { EmailMarketSchema, type EmailMarket } from './EmailMarket';
+export { EmailNewsletterSubscriberSchema, type EmailNewsletterSubscriber } from './EmailNewsletterSubscriber';
export { EmailOptionValueSchema, type EmailOptionValue } from './EmailOptionValue';
export { EmailOrderSchema, type EmailOrder } from './EmailOrder';
export { EmailOrderGroupSchema, type EmailOrderGroup } from './EmailOrderGroup';
diff --git a/packages/dashboard/src/lib/email-template-variables.ts b/packages/dashboard/src/lib/email-template-variables.ts
index a6e9a0d68d..8ad9e9290d 100644
--- a/packages/dashboard/src/lib/email-template-variables.ts
+++ b/packages/dashboard/src/lib/email-template-variables.ts
@@ -1,6 +1,6 @@
import type {
Company,
- Customer,
+ EmailCustomer,
EmailFulfillment,
EmailOrder,
EmailOrderGroup,
@@ -8,6 +8,7 @@ import type {
EmailStore,
} from '@spree/admin-sdk'
import {
+ EmailCustomerSchema,
EmailFulfillmentSchema,
EmailOrderGroupSchema,
EmailOrderSchema,
@@ -145,11 +146,11 @@ export const EMAIL_TEMPLATE_VARIABLES: Record<string, EmailTemplateVariable[]> =
],
'spree.digital_asset_mailer.files_ready_email': [order, variable('downloads'), resend],
'spree.customer_mailer.password_reset_email': [
- variable('customer', [
- 'first_name',
- 'last_name',
- 'email',
- ] as const satisfies FieldsOf<Customer>),
+ variable(
+ 'customer',
+ ['first_name', 'last_name', 'email'] as const satisfies FieldsOf<EmailCustomer>,
+ EmailCustomerSchema,
+ ),
variable('reset_url'),
],
'spree.customer_mailer.data_export_email': [variable('download_url'), variable('expires_at')],
diff --git a/spree/api/app/serializers/spree/api/v3/base_serializer.rb b/spree/api/app/serializers/spree/api/v3/base_serializer.rb
index a3ec20a139..59c7a6dccd 100644
--- a/spree/api/app/serializers/spree/api/v3/base_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/base_serializer.rb
@@ -26,11 +26,18 @@ module Spree
#
# @param surface [Symbol] :admin or :seller, whose price serializers to use
def self.without_formatted_money(surface = :admin)
- _attributes.delete_if { |key, _| key.to_s.start_with?('display_') && !FORMATTED_LABELS.include?(key.to_sym) }
+ without_display_money
define_method(:price_serializer) { Spree.api.public_send(:"#{surface}_price_serializer") }
define_method(:price_history_serializer) { Spree.api.public_send(:"#{surface}_price_history_serializer") }
end
+ # Drops the inherited display_* money attributes, keeping labels.
+ # Emails use it alone: their templates format amounts with the `money`
+ # Liquid filter.
+ def self.without_display_money
+ _attributes.delete_if { |key, _| key.to_s.start_with?('display_') && !FORMATTED_LABELS.include?(key.to_sym) }
+ end
+
# Declares money attributes, written as decimal strings with exactly
# the currency's decimal places ("10.00", "1.500", "100"), or up to
# four for unit prices ("0.0125"). +display_*+ names pass through as
diff --git a/spree/emails/README.md b/spree/emails/README.md
index 895dace66d..e608e8e58d 100644
--- a/spree/emails/README.md
+++ b/spree/emails/README.md
@@ -73,7 +73,7 @@ module Spree
@current_store = store
with_store_locale(@current_store) do
- mail_template({ customer: email_data(customer, Spree.api.customer_serializer) }, to: customer.email)
+ mail_template({ customer: email_data(customer, Spree::Emails::CustomerSerializer) }, to: customer.email)
end
end
end
diff --git a/spree/emails/app/mailers/spree/customer_mailer.rb b/spree/emails/app/mailers/spree/customer_mailer.rb
index 222620cca5..91aa350205 100644
--- a/spree/emails/app/mailers/spree/customer_mailer.rb
+++ b/spree/emails/app/mailers/spree/customer_mailer.rb
@@ -11,7 +11,7 @@ module Spree
with_store_locale(store) do
mail_template(
- { customer: email_data(user, Spree.api.customer_serializer), reset_url: @reset_url },
+ { customer: email_data(user, Spree::Emails::CustomerSerializer), reset_url: @reset_url },
to: user.email, store_url: store.storefront_url
)
end
diff --git a/spree/emails/app/serializers/spree/emails/amount_line_serializer.rb b/spree/emails/app/serializers/spree/emails/amount_line_serializer.rb
index 34c54f3492..9b76fd6133 100644
--- a/spree/emails/app/serializers/spree/emails/amount_line_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/amount_line_serializer.rb
@@ -5,10 +5,6 @@ module Spree
attributes :label
- attribute :display_amount do |line|
- line.display_amount.to_s
- end
-
attribute :amount do |line|
Spree::Money::Rounding.format(line.amount, line.currency)
end
diff --git a/spree/emails/app/serializers/spree/emails/applied_promotion_serializer.rb b/spree/emails/app/serializers/spree/emails/applied_promotion_serializer.rb
index 8a0bcc7fbc..d9ea6ef83a 100644
--- a/spree/emails/app/serializers/spree/emails/applied_promotion_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/applied_promotion_serializer.rb
@@ -1,6 +1,7 @@
module Spree
module Emails
class AppliedPromotionSerializer < Spree::Api::V3::AppliedPromotionSerializer
+ without_display_money
end
end
end
diff --git a/spree/emails/app/serializers/spree/emails/customer_group_serializer.rb b/spree/emails/app/serializers/spree/emails/customer_group_serializer.rb
new file mode 100644
index 0000000000..a98a8e0135
--- /dev/null
+++ b/spree/emails/app/serializers/spree/emails/customer_group_serializer.rb
@@ -0,0 +1,6 @@
+module Spree
+ module Emails
+ class CustomerGroupSerializer < Spree::Api::V3::CustomerGroupSerializer
+ end
+ end
+end
diff --git a/spree/emails/app/serializers/spree/emails/customer_serializer.rb b/spree/emails/app/serializers/spree/emails/customer_serializer.rb
new file mode 100644
index 0000000000..e68c67fd79
--- /dev/null
+++ b/spree/emails/app/serializers/spree/emails/customer_serializer.rb
@@ -0,0 +1,19 @@
+module Spree
+ module Emails
+ class CustomerSerializer < Spree::Api::V3::CustomerSerializer
+ without_display_money
+
+ many :addresses, resource: Spree::Emails::AddressSerializer
+ one :bill_address, key: :default_billing_address, resource: Spree::Emails::AddressSerializer
+ one :ship_address, key: :default_shipping_address, resource: Spree::Emails::AddressSerializer
+
+ one :newsletter_subscriber, resource: Spree::Emails::NewsletterSubscriberSerializer do |user, params|
+ user.newsletter_subscriber(params&.dig(:store) || Spree::Current.store)
+ end
+
+ many :customer_groups,
+ proc { |groups, params| groups.for_store(params&.dig(:store) || Spree::Current.store) },
+ resource: Spree::Emails::CustomerGroupSerializer
+ end
+ end
+end
diff --git a/spree/emails/app/serializers/spree/emails/delivery_rate_serializer.rb b/spree/emails/app/serializers/spree/emails/delivery_rate_serializer.rb
index 264957fabd..b832302fc9 100644
--- a/spree/emails/app/serializers/spree/emails/delivery_rate_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/delivery_rate_serializer.rb
@@ -1,6 +1,8 @@
module Spree
module Emails
class DeliveryRateSerializer < Spree::Api::V3::DeliveryRateSerializer
+ without_display_money
+
typelize freight_summary: [:EmailFreightSummary, nullable: true]
one :freight_summary, resource: Spree::Emails::FreightSummarySerializer
diff --git a/spree/emails/app/serializers/spree/emails/fee_serializer.rb b/spree/emails/app/serializers/spree/emails/fee_serializer.rb
index d1f5e78409..535106806b 100644
--- a/spree/emails/app/serializers/spree/emails/fee_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/fee_serializer.rb
@@ -1,6 +1,7 @@
module Spree
module Emails
class FeeSerializer < Spree::Api::V3::FeeSerializer
+ without_display_money
end
end
end
diff --git a/spree/emails/app/serializers/spree/emails/fulfillment_group_serializer.rb b/spree/emails/app/serializers/spree/emails/fulfillment_group_serializer.rb
index 1dc95ab94f..dac6f4ae14 100644
--- a/spree/emails/app/serializers/spree/emails/fulfillment_group_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/fulfillment_group_serializer.rb
@@ -14,10 +14,6 @@ module Spree
Spree::Money::Rounding.format(group.cost, group.currency)
end
- attribute :display_cost do |group|
- group.display_cost.to_s
- end
-
attribute :seller_names do |group|
group.sellers.map(&:name)
end
diff --git a/spree/emails/app/serializers/spree/emails/fulfillment_serializer.rb b/spree/emails/app/serializers/spree/emails/fulfillment_serializer.rb
index ae391a0a78..b41a4477b4 100644
--- a/spree/emails/app/serializers/spree/emails/fulfillment_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/fulfillment_serializer.rb
@@ -1,6 +1,8 @@
module Spree
module Emails
class FulfillmentSerializer < Spree::Api::V3::FulfillmentSerializer
+ without_display_money
+
typelize delivery_method_name: [:string, nullable: true]
attribute :delivery_method_name do |fulfillment|
diff --git a/spree/emails/app/serializers/spree/emails/gift_card_serializer.rb b/spree/emails/app/serializers/spree/emails/gift_card_serializer.rb
index ff6da8d5f7..cbf5eb5f22 100644
--- a/spree/emails/app/serializers/spree/emails/gift_card_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/gift_card_serializer.rb
@@ -1,6 +1,7 @@
module Spree
module Emails
class GiftCardSerializer < Spree::Api::V3::GiftCardSerializer
+ without_display_money
end
end
end
diff --git a/spree/emails/app/serializers/spree/emails/line_item_serializer.rb b/spree/emails/app/serializers/spree/emails/line_item_serializer.rb
index 9da5850437..c493be6bbe 100644
--- a/spree/emails/app/serializers/spree/emails/line_item_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/line_item_serializer.rb
@@ -3,9 +3,11 @@ module Spree
class LineItemSerializer < Spree::Api::V3::LineItemSerializer
include Spree::Emails::PurchasedItemAttributes
+ without_display_money
+
many :option_values, resource: Spree::Emails::OptionValueSerializer
- typelize sku: [:string, nullable: true], amount: :string, display_amount: :string,
+ typelize sku: [:string, nullable: true], amount: :string,
url: [:string, nullable: true], image_url: [:string, nullable: true]
attributes :sku
@@ -15,10 +17,6 @@ module Spree
Spree::Money::Rounding.format(line_item.amount, line_item.currency)
end
- attribute :display_amount do |line_item|
- line_item.display_amount.to_s
- end
-
# The full-size image; emails show the thumbnail in `image_url`.
attributes :thumbnail_url, if: proc { false }
end
diff --git a/spree/emails/app/serializers/spree/emails/newsletter_subscriber_serializer.rb b/spree/emails/app/serializers/spree/emails/newsletter_subscriber_serializer.rb
new file mode 100644
index 0000000000..30ba27383c
--- /dev/null
+++ b/spree/emails/app/serializers/spree/emails/newsletter_subscriber_serializer.rb
@@ -0,0 +1,6 @@
+module Spree
+ module Emails
+ class NewsletterSubscriberSerializer < Spree::Api::V3::NewsletterSubscriberSerializer
+ end
+ end
+end
diff --git a/spree/emails/app/serializers/spree/emails/order_group_serializer.rb b/spree/emails/app/serializers/spree/emails/order_group_serializer.rb
index c74998be9d..8078ec248f 100644
--- a/spree/emails/app/serializers/spree/emails/order_group_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/order_group_serializer.rb
@@ -5,10 +5,10 @@ module Spree
class OrderGroupSerializer < Spree::Api::V3::OrderGroupSerializer
include Spree::Emails::PurchaseSummaryAttributes
- typelize po_number: [:string, nullable: true], order_count: :number,
- delivery_total: :string, display_delivery_total: :string,
- additional_tax_total: :string, display_additional_tax_total: :string,
- gift_card_total: :string, display_gift_card_total: :string
+ without_display_money
+
+ typelize po_number: [:string, nullable: true], order_count: :number, delivery_total: :string,
+ additional_tax_total: :string, gift_card_total: :string
attributes :po_number
@@ -16,10 +16,6 @@ module Spree
group.orders.size
end
- attribute :display_delivery_total do |group|
- group.display_delivery_total.to_s
- end
-
attribute :delivery_total do |group|
Spree::Money::Rounding.format(group.delivery_total, group.currency)
end
@@ -28,18 +24,10 @@ module Spree
Spree::Money::Rounding.format(group.additional_tax_total, group.currency)
end
- attribute :display_additional_tax_total do |group|
- group.display_additional_tax_total.to_s
- end
-
attribute :gift_card_total do |group|
Spree::Money::Rounding.format(group.gift_card_total, group.currency)
end
- attribute :display_gift_card_total do |group|
- group.display_gift_card_total.to_s
- end
-
many :payments, resource: Spree::Emails::PaymentSerializer
# Every child order in full is what the webhook payload carries; the
diff --git a/spree/emails/app/serializers/spree/emails/order_serializer.rb b/spree/emails/app/serializers/spree/emails/order_serializer.rb
index 26c3064443..15ebdfb9bd 100644
--- a/spree/emails/app/serializers/spree/emails/order_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/order_serializer.rb
@@ -5,6 +5,8 @@ module Spree
class OrderSerializer < Spree::Api::V3::OrderSerializer
include Spree::Emails::PurchaseSummaryAttributes
+ without_display_money
+
many :order_promotions, key: :discounts, resource: Spree::Emails::AppliedPromotionSerializer
many :fees, resource: Spree::Emails::FeeSerializer
many :fulfillments, resource: Spree::Emails::FulfillmentSerializer
diff --git a/spree/emails/app/serializers/spree/emails/parcel_item_serializer.rb b/spree/emails/app/serializers/spree/emails/parcel_item_serializer.rb
index 7d1395e260..1b55c865a4 100644
--- a/spree/emails/app/serializers/spree/emails/parcel_item_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/parcel_item_serializer.rb
@@ -31,14 +31,6 @@ module Spree
attribute :amount do |item|
Spree::Money::Rounding.format(item.line_item.price * item.quantity, item.line_item.currency)
end
-
- attribute :display_price do |item|
- item.line_item.display_price.to_s
- end
-
- attribute :display_amount do |item|
- Spree::Money.new(item.line_item.price * item.quantity, currency: item.line_item.currency).to_s
- end
end
end
end
diff --git a/spree/emails/app/serializers/spree/emails/payment_serializer.rb b/spree/emails/app/serializers/spree/emails/payment_serializer.rb
index 837d311583..3fdf925a42 100644
--- a/spree/emails/app/serializers/spree/emails/payment_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/payment_serializer.rb
@@ -1,6 +1,8 @@
module Spree
module Emails
class PaymentSerializer < Spree::Api::V3::PaymentSerializer
+ without_display_money
+
typelize source: ['Record<string, unknown>', nullable: true]
one :payment_method, resource: Spree::Emails::PaymentMethodSerializer
diff --git a/spree/emails/app/serializers/spree/emails/purchase_summary_attributes.rb b/spree/emails/app/serializers/spree/emails/purchase_summary_attributes.rb
index 657147e2a1..69caa1344d 100644
--- a/spree/emails/app/serializers/spree/emails/purchase_summary_attributes.rb
+++ b/spree/emails/app/serializers/spree/emails/purchase_summary_attributes.rb
@@ -7,7 +7,7 @@ module Spree
extend ActiveSupport::Concern
included do
- typelize customer_name: :string, total_minus_store_credits: :string, display_total_minus_store_credits: :string
+ typelize customer_name: :string, total_minus_store_credits: :string
attribute :customer_name do |purchase|
purchase.name.presence || I18n.t('spree.customer')
@@ -17,10 +17,6 @@ module Spree
Spree::Money::Rounding.format(purchase.total_minus_store_credits, purchase.currency)
end
- attribute :display_total_minus_store_credits do |purchase|
- purchase.display_total_minus_store_credits.to_s
- end
-
many :line_items, key: :items, resource: Spree::Emails::LineItemSerializer
one :billing_address, resource: Spree::Emails::AddressSerializer
one :shipping_address, resource: Spree::Emails::AddressSerializer
diff --git a/spree/emails/app/serializers/spree/emails/return_serializer.rb b/spree/emails/app/serializers/spree/emails/return_serializer.rb
index 0c157388be..2230fb12d8 100644
--- a/spree/emails/app/serializers/spree/emails/return_serializer.rb
+++ b/spree/emails/app/serializers/spree/emails/return_serializer.rb
@@ -1,7 +1,9 @@
module Spree
module Emails
class ReturnSerializer < Spree::Api::V3::ReturnSerializer
- typelize refunded_total: :string, display_refunded_total: :string
+ without_display_money
+
+ typelize refunded_total: :string
# What was actually paid back — not the Store API's refund_total, which
# is the figure the return was expected to refund.
@@ -9,10 +11,6 @@ module Spree
Spree::Money::Rounding.format(return_record.refunded_total, return_record.currency)
end
- attribute :display_refunded_total do |return_record|
- return_record.display_refunded_total.to_s
- end
-
many :returned_items,
source: proc { return_line_items.filter_map(&:line_item).uniq },
resource: Spree::Emails::LineItemSerializer
diff --git a/spree/emails/app/services/spree/emails/samples/password_reset.rb b/spree/emails/app/services/spree/emails/samples/password_reset.rb
index 395c64beef..1ab5800357 100644
--- a/spree/emails/app/services/spree/emails/samples/password_reset.rb
+++ b/spree/emails/app/services/spree/emails/samples/password_reset.rb
@@ -5,7 +5,7 @@ module Spree
def variables
{
customer: data(Spree.customer_class.new(first_name: 'Jane', last_name: 'Doe', email: '[email protected]'),
- Spree.api.customer_serializer),
+ Spree::Emails::CustomerSerializer),
reset_url: placeholder_url('account/reset-password')
}
end
diff --git a/spree/emails/config/initializers/typelizer.rb b/spree/emails/config/initializers/typelizer.rb
index e44a4a7f4c..922c97cf14 100644
--- a/spree/emails/config/initializers/typelizer.rb
+++ b/spree/emails/config/initializers/typelizer.rb
@@ -12,16 +12,15 @@ Rails.application.config.after_initialize do
serializer.extend(Typelizer::DSL) unless serializer.respond_to?(:typelize)
end
- Spree::Emails::AmountLineSerializer.typelize(label: [:string, nullable: true], amount: :string, display_amount: :string)
+ Spree::Emails::AmountLineSerializer.typelize(label: [:string, nullable: true], amount: :string)
Spree::Emails::FulfillmentGroupSerializer.typelize(name: [:string, nullable: true], unpriced: :boolean, cost: :string,
- display_cost: :string,
seller_names: [:string, multi: true],
# Declared before Typelizer's hooks were attached, so it
# cannot tell this association is a list.
items: [:EmailParcelItem, multi: true])
Spree::Emails::ParcelItemSerializer.typelize(
id: :string, name: :string, quantity: :number, sku: [:string, nullable: true], options_text: [:string, nullable: true],
- price: :string, amount: :string, display_price: :string, display_amount: :string, url: [:string, nullable: true],
+ price: :string, amount: :string, url: [:string, nullable: true],
image_url: [:string, nullable: true]
)
Spree::Emails::StoreSerializer.typelize(
diff --git a/spree/emails/spec/services/spree/emails/samples_spec.rb b/spree/emails/spec/services/spree/emails/samples_spec.rb
index 17b93840f4..5483ab88d4 100644
--- a/spree/emails/spec/services/spree/emails/samples_spec.rb
+++ b/spree/emails/spec/services/spree/emails/samples_spec.rb
@@ -28,6 +28,26 @@ describe 'editable email samples' do
end
end
+ # Templates format amounts with the `money` filter, in the email's language.
+ it 'sends amounts without formatted money copies, nested records included' do
+ labels = Spree::Api::V3::BaseSerializer::FORMATTED_LABELS.map(&:to_s)
+ formatted_keys = lambda do |node|
+ case node
+ when Hash then node.flat_map { |key, value| (key.to_s.start_with?('display_') && labels.exclude?(key.to_s) ? [key] : []) + formatted_keys.call(value) }
+ when Array then node.flat_map(&formatted_keys)
+ else []
+ end
+ end
+
+ found = Spree.editable_email_templates.emails.to_h do |email|
+ preview = Spree::EmailTemplates::Preview.new(store: store, key: email.key)
+ preview.call
+ [email.key, formatted_keys.call(preview.variables.as_json).uniq]
+ end
+
+ expect(found.reject { |_, keys| keys.empty? }).to eq({})
+ end
+
it 'previews with a record the merchant picks, only from the store' do
order = create(:completed_order_with_totals, store: store)