Skip to content

Commit

Permalink
update checkout order handling to include order number in URL (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
emipallares authored Nov 26, 2024
1 parent b92c237 commit 24012e9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions blocks/commerce-checkout/commerce-checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 24012e9

Please sign in to comment.