From 7a45b243cb04ecf382bb34e63ae3b5930aa0f6dd Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Thu, 8 Jan 2026 23:23:56 +0700 Subject: [PATCH] fix: ThankYou page discount rows and improved hidden field detection 1. ThankYou page - Added discount row to order summary - All 3 template variations (receipt-inner, receipt-outer, default) - Shows discount with negative amount in green when > 0 - Already had shipping/tax rows, now complete breakdown 2. Checkout - Enhanced isFieldHidden helper - Now checks both type='hidden' AND hidden=true flags - Any standard field can be hidden via PHP snippet - Existing city/state/postcode/country checks unchanged --- customer-spa/src/pages/Checkout/index.tsx | 5 +++-- customer-spa/src/pages/ThankYou/index.tsx | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/customer-spa/src/pages/Checkout/index.tsx b/customer-spa/src/pages/Checkout/index.tsx index 2efe0ac..1b9720b 100644 --- a/customer-spa/src/pages/Checkout/index.tsx +++ b/customer-spa/src/pages/Checkout/index.tsx @@ -222,10 +222,11 @@ export default function Checkout() { loadCheckoutFields(); }, [cart.items, isVirtualOnly]); - // Helper to check if a standard field should be hidden (set to type: 'hidden' in PHP) + // Helper to check if a standard field should be hidden (set to type: 'hidden' or hidden: true in PHP) const isFieldHidden = (fieldKey: string): boolean => { const field = checkoutFields.find(f => f.key === fieldKey); - return field?.type === 'hidden'; + // Check both type='hidden' and the hidden flag from API + return field?.type === 'hidden' || field?.hidden === true; }; // Filter custom fields by fieldset diff --git a/customer-spa/src/pages/ThankYou/index.tsx b/customer-spa/src/pages/ThankYou/index.tsx index d1d1845..f0a556c 100644 --- a/customer-spa/src/pages/ThankYou/index.tsx +++ b/customer-spa/src/pages/ThankYou/index.tsx @@ -147,6 +147,12 @@ export default function ThankYou() { {formatPrice(parseFloat(order.tax_total))} )} + {parseFloat(order.discount_total || 0) > 0 && ( +
+ DISCOUNT: + -{formatPrice(parseFloat(order.discount_total))} +
+ )}
TOTAL: {formatPrice(parseFloat(order.total || 0))} @@ -263,6 +269,12 @@ export default function ThankYou() { {formatPrice(parseFloat(order.tax_total))}
)} + {parseFloat(order.discount_total || 0) > 0 && ( +
+ DISCOUNT: + -{formatPrice(parseFloat(order.discount_total))} +
+ )}
TOTAL: {formatPrice(parseFloat(order.total || 0))} @@ -415,6 +427,12 @@ export default function ThankYou() { {formatPrice(parseFloat(order.tax_total))}
)} + {parseFloat(order.discount_total || 0) > 0 && ( +
+ Discount + -{formatPrice(parseFloat(order.discount_total))} +
+ )}
Total {formatPrice(parseFloat(order.total || 0))}