From 2dc86db8d4d6cd89e713918bfc37b3ed4eb9d209 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 10 Oct 2024 19:49:30 +0200 Subject: [PATCH] Show selected method in apple window on load --- resources/js/blocks/ApplePayButtonComponent.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/js/blocks/ApplePayButtonComponent.js b/resources/js/blocks/ApplePayButtonComponent.js index 78bd5529..5a7505f3 100644 --- a/resources/js/blocks/ApplePayButtonComponent.js +++ b/resources/js/blocks/ApplePayButtonComponent.js @@ -14,7 +14,14 @@ export const ApplePayButtonComponent = ({cart, extensions}) => { const findSelectedShippingMethod = (shippingRates) => { let shippingRate = shippingRates.find((shippingMethod) => shippingMethod.selected === true) - return shippingRate ? shippingRate.rate_id : '' + const appleFormattedRate = { + amount: '', + detail: '', + label: shippingRate.name, + identifier: shippingRate.rate_id, + selected: shippingRate.selected, + } + return shippingRate ? appleFormattedRate : '' } let applePaySession = () => { @@ -23,7 +30,6 @@ export const ApplePayButtonComponent = ({cart, extensions}) => { const shippingRates = store.getShippingRates()[0].shipping_rates let selectedShippingMethod = findSelectedShippingMethod(shippingRates, selectedShippingMethod) session.onshippingmethodselected = function (event) { - console.log(selectedShippingMethod) jQuery.ajax({ url: ajaxUrl, method: 'POST', @@ -61,6 +67,7 @@ export const ApplePayButtonComponent = ({cart, extensions}) => { callerPage: 'cart', needShipping: needShipping, 'woocommerce-process-checkout-nonce': nonce, + shippingMethod: selectedShippingMethod, }, complete: (jqXHR, textStatus) => { },