From 24012e92372f75dc16e6f49c6aab69d7a683f447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emi=20Pallar=C3=A8s?= <100593045+emipallares@users.noreply.github.com> Date: Tue, 26 Nov 2024 10:49:36 +0100 Subject: [PATCH] update checkout order handling to include order number in URL (#214) --- blocks/commerce-checkout/commerce-checkout.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/blocks/commerce-checkout/commerce-checkout.js b/blocks/commerce-checkout/commerce-checkout.js index 6db82342a..44bafc57e 100644 --- a/blocks/commerce-checkout/commerce-checkout.js +++ b/blocks/commerce-checkout/commerce-checkout.js @@ -812,19 +812,21 @@ export default async function decorate(block) { }; const handleCheckoutOrder = async (orderData) => { - // clear address form data + // Clear address form data sessionStorage.removeItem(SHIPPING_ADDRESS_DATA_KEY); sessionStorage.removeItem(BILLING_ADDRESS_DATA_KEY); const token = getUserTokenCookie(); const orderRef = token ? orderData.number : orderData.token; + const orderNumber = orderData.number; const encodedOrderRef = encodeURIComponent(orderRef); + const encodedOrderNumber = encodeURIComponent(orderNumber); - window.history.pushState( - {}, - '', - `/order-details?orderRef=${encodedOrderRef}`, - ); + const url = token + ? `/order-details?orderRef=${encodedOrderRef}` + : `/order-details?orderRef=${encodedOrderRef}&orderNumber=${encodedOrderNumber}`; + + window.history.pushState({}, '', url); // TODO cleanup checkout containers await displayOrderConfirmation(orderData);