Skip to content

Commit

Permalink
Create return routing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferri0 committed Dec 6, 2024
1 parent 52d459b commit fcbef3b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion blocks/commerce-create-return/commerce-create-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import '../../scripts/initializers/order.js';

export default async function decorate(block) {
await orderRenderer.render(CreateReturn, {
routeReturnSuccess: (orderData) => (checkIsAuthenticated() ? `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderData.number}` : `${ORDER_DETAILS_PATH}?orderRef=${orderData.token}`),
routeReturnSuccess: (orderData) => {
const orderRef = checkIsAuthenticated() ? orderData.number : orderData.token;
const encodedOrderRef = encodeURIComponent(orderRef);
const path = checkIsAuthenticated() ? CUSTOMER_ORDER_DETAILS_PATH : ORDER_DETAILS_PATH;

return `${path}?orderRef=${encodedOrderRef}`;
},
})(block);
}

0 comments on commit fcbef3b

Please sign in to comment.