From fcbef3b082e1c7768e7603c8763a3012b394da50 Mon Sep 17 00:00:00 2001 From: Abrasimov Yaroslav Date: Fri, 6 Dec 2024 22:25:18 +0100 Subject: [PATCH] Create return routing fix --- blocks/commerce-create-return/commerce-create-return.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/blocks/commerce-create-return/commerce-create-return.js b/blocks/commerce-create-return/commerce-create-return.js index 5f1e325b2b..9b4c30994e 100644 --- a/blocks/commerce-create-return/commerce-create-return.js +++ b/blocks/commerce-create-return/commerce-create-return.js @@ -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); }