fix(invoice): localize Shopify payment-gateway names on the PDF
Customer reported that on the German invoice PDF the payment method showed up as 'Zahlart: Bank Deposit' while the order-confirmation page on the storefront localized it correctly to 'Bank\u00fc1berweisung'. Cause: Shopify's Admin GraphQL API only ever returns the *English* template name in 'Order.paymentGatewayNames', even when the shop / order locale is German \u2014 the localization happens client-side at checkout but is NOT exposed via the API. So the PDF and the storefront naturally diverge unless we mirror the translations ourselves. Fix: introduce a per-language 'paymentGatewayLabels' map on 'InvoiceStrings' covering the built-in Shopify manual-payment templates (Bank Deposit, Money Order, Cash on Delivery) plus the standard non-manual gateways (Shopify Payments, PayPal, Klarna, Sofort, Giropay, Bogus). 'prettifyGatewayName' now takes this map and looks up the normalized key (lowercased, separators collapsed), falling back to a title-cased rendering for unknown values. DE result: 'Zahlart: Bank\u00fc1berweisung', 'Manuelle Zahlung', 'Nachnahme'. EN result: unchanged. New smoke assertions verify the DE PDF now shows 'Manuelle Zahlung' for the AT B2B fixture's 'manual' gateway and that the raw English 'Manual' no longer appears next to the 'Zahlart' label. Note on other Shopify-sourced strings on the PDF: 'shippingLine.title' (e.g. 'Standard') is similarly merchant/locale-dependent, but unlike gateway names it's fully customizable per-shop in Shopify Admin and is not a fixed enum we can translate \u2014 left untouched pending an explicit report. Product titles, discount codes and addresses are likewise merchant-/customer-supplied and flow through verbatim by design.
This commit is contained in:
@@ -554,6 +554,14 @@ async function main() {
|
||||
assert("DE PDF shows payment status row", deText.includes("Zahlstatus"));
|
||||
assert("DE PDF shows payment status value 'Offen' for PENDING", deText.includes("Offen"));
|
||||
assert("DE PDF shows payment method row", deText.includes("Zahlart"));
|
||||
// The Shopify Admin GraphQL API returns the *English* template name for
|
||||
// built-in manual payment gateways even on German-locale shops — we
|
||||
// localize it ourselves via i18n.paymentGatewayLabels so the PDF matches
|
||||
// what the customer saw on the order-confirmation page.
|
||||
assert("DE PDF localizes 'manual' gateway to 'Manuelle Zahlung'",
|
||||
deText.includes("Manuelle Zahlung"));
|
||||
assert("DE PDF no longer shows raw English 'Manual' as gateway label",
|
||||
!/Zahlart[\s\S]{0,20}Manual\b/.test(deText));
|
||||
assert("EN PDF shows payment status row", enText.includes("Payment status"));
|
||||
assert("EN PDF shows payment status value 'Outstanding' for PENDING", enText.includes("Outstanding"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user