mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Default to wc data when filling checkout
This commit is contained in:
parent
539e211e6b
commit
14f54e1df1
3 changed files with 13 additions and 2 deletions
|
@ -10,7 +10,8 @@
|
|||
"Edge >= 14"
|
||||
],
|
||||
"dependencies": {
|
||||
"core-js": "^3.25.0"
|
||||
"core-js": "^3.25.0",
|
||||
"deepmerge": "^4.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.19",
|
||||
|
|
|
@ -3,6 +3,7 @@ import {registerExpressPaymentMethod, registerPaymentMethod} from '@woocommerce/
|
|||
import {paypalAddressToWc, paypalOrderToWcAddresses} from "./Helper/Address";
|
||||
import {loadPaypalScript} from '../../../ppcp-button/resources/js/modules/Helper/ScriptLoading'
|
||||
import buttonModuleWatcher from "../../../ppcp-button/resources/js/modules/ButtonModuleWatcher";
|
||||
import merge from "deepmerge";
|
||||
|
||||
const config = wc.wcSettings.getSetting('ppcp-gateway_data');
|
||||
|
||||
|
@ -29,7 +30,11 @@ const PayPalComponent = ({
|
|||
if (!config.scriptData.continuation || !config.scriptData.continuation.order || window.ppcpContinuationFilled) {
|
||||
return;
|
||||
}
|
||||
const addresses = paypalOrderToWcAddresses(config.scriptData.continuation.order);
|
||||
const paypalAddresses = paypalOrderToWcAddresses(config.scriptData.continuation.order);
|
||||
const wcAddresses = wp.data.select('wc/store/cart').getCustomerData();
|
||||
const addresses = merge(wcAddresses, paypalAddresses, {
|
||||
customMerge: key => (a, b) => a ? a : b, // overwrite empty strings
|
||||
});
|
||||
wp.data.dispatch('wc/store/cart').setBillingAddress(addresses.billingAddress);
|
||||
if (shippingData.needsShipping) {
|
||||
wp.data.dispatch('wc/store/cart').setShippingAddress(addresses.shippingAddress);
|
||||
|
|
|
@ -1425,6 +1425,11 @@ debug@^4.1.0, debug@^4.1.1:
|
|||
dependencies:
|
||||
ms "2.1.2"
|
||||
|
||||
deepmerge@^4.3.1:
|
||||
version "4.3.1"
|
||||
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.3.1.tgz#44b5f2147cd3b00d4b56137685966f26fd25dd4a"
|
||||
integrity sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==
|
||||
|
||||
electron-to-chromium@^1.4.251:
|
||||
version "1.4.284"
|
||||
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.284.tgz#61046d1e4cab3a25238f6bf7413795270f125592"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue