Skip to content

Commit

Permalink
Show selected method in apple window on load
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Oct 10, 2024
1 parent 9fae4de commit 2dc86db
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions resources/js/blocks/ApplePayButtonComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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',
Expand Down Expand Up @@ -61,6 +67,7 @@ export const ApplePayButtonComponent = ({cart, extensions}) => {
callerPage: 'cart',
needShipping: needShipping,
'woocommerce-process-checkout-nonce': nonce,
shippingMethod: selectedShippingMethod,
},
complete: (jqXHR, textStatus) => {
},
Expand Down

0 comments on commit 2dc86db

Please sign in to comment.