Do not fail when cannot fill form in block continuation

This commit is contained in:
Alex P 2023-11-29 11:58:41 +02:00
parent 7cfa376456
commit dc2c60a6f2
No known key found for this signature in database
GPG key ID: 54487A734A204D71

View file

@ -39,12 +39,17 @@ const PayPalComponent = ({
if (!config.scriptData.continuation || !config.scriptData.continuation.order || window.ppcpContinuationFilled) { if (!config.scriptData.continuation || !config.scriptData.continuation.order || window.ppcpContinuationFilled) {
return; return;
} }
const paypalAddresses = paypalOrderToWcAddresses(config.scriptData.continuation.order); try {
const wcAddresses = wp.data.select('wc/store/cart').getCustomerData(); const paypalAddresses = paypalOrderToWcAddresses(config.scriptData.continuation.order);
const addresses = mergeWcAddress(wcAddresses, paypalAddresses); const wcAddresses = wp.data.select('wc/store/cart').getCustomerData();
wp.data.dispatch('wc/store/cart').setBillingAddress(addresses.billingAddress); const addresses = mergeWcAddress(wcAddresses, paypalAddresses);
if (shippingData.needsShipping) { wp.data.dispatch('wc/store/cart').setBillingAddress(addresses.billingAddress);
wp.data.dispatch('wc/store/cart').setShippingAddress(addresses.shippingAddress); if (shippingData.needsShipping) {
wp.data.dispatch('wc/store/cart').setShippingAddress(addresses.shippingAddress);
}
} catch (err) {
// sometimes the PayPal address is missing, skip in this case.
console.log(err);
} }
// this useEffect should run only once, but adding this in case of some kind of full re-rendering // this useEffect should run only once, but adding this in case of some kind of full re-rendering
window.ppcpContinuationFilled = true; window.ppcpContinuationFilled = true;