mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge pull request #2633 from woocommerce/PCP-3725-changing-shipping-address-or-card-in-wc-9-4
Add backwards compatibility when address editing state toggling is not available (3725)
This commit is contained in:
commit
86e55b6274
2 changed files with 25 additions and 8 deletions
|
@ -83,10 +83,16 @@ export const populateWooFields = (
|
|||
profileData
|
||||
);
|
||||
|
||||
// Disable the 'Use same address for billing' checkbox
|
||||
dispatch( CHECKOUT_STORE_KEY ).__internalSetUseShippingAsBilling( false );
|
||||
const checkoutDispatch = dispatch( CHECKOUT_STORE_KEY );
|
||||
|
||||
// Save shipping address
|
||||
// Uncheck the 'Use same address for billing' checkbox if the method exists.
|
||||
if (
|
||||
typeof checkoutDispatch.__internalSetUseShippingAsBilling === 'function'
|
||||
) {
|
||||
checkoutDispatch.__internalSetUseShippingAsBilling( false );
|
||||
}
|
||||
|
||||
// Save shipping address.
|
||||
const { address, name, phoneNumber } = profileData.shippingAddress;
|
||||
|
||||
const shippingAddress = {
|
||||
|
@ -104,7 +110,7 @@ export const populateWooFields = (
|
|||
console.log( 'Setting WooCommerce shipping address:', shippingAddress );
|
||||
setWooShippingAddress( shippingAddress );
|
||||
|
||||
// Save billing address
|
||||
// Save billing address.
|
||||
const billingData = profileData.card.paymentSource.card.billingAddress;
|
||||
|
||||
const billingAddress = {
|
||||
|
@ -121,6 +127,13 @@ export const populateWooFields = (
|
|||
console.log( 'Setting WooCommerce billing address:', billingAddress );
|
||||
setWooBillingAddress( billingAddress );
|
||||
|
||||
dispatch( CHECKOUT_STORE_KEY ).setEditingShippingAddress( false );
|
||||
dispatch( CHECKOUT_STORE_KEY ).setEditingBillingAddress( false );
|
||||
// Collapse shipping address input fields into the card view.
|
||||
if ( typeof checkoutDispatch.setEditingShippingAddress === 'function' ) {
|
||||
checkoutDispatch.setEditingShippingAddress( false );
|
||||
}
|
||||
|
||||
// Collapse billing address input fields into the card view.
|
||||
if ( typeof checkoutDispatch.setEditingBillingAddress === 'function' ) {
|
||||
checkoutDispatch.setEditingBillingAddress( false );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -24,14 +24,18 @@ export const useAddressEditing = () => {
|
|||
|
||||
const setShippingAddressEditing = useCallback(
|
||||
( isEditing ) => {
|
||||
setEditingShippingAddress( isEditing );
|
||||
if ( typeof setEditingShippingAddress === 'function' ) {
|
||||
setEditingShippingAddress( isEditing );
|
||||
}
|
||||
},
|
||||
[ setEditingShippingAddress ]
|
||||
);
|
||||
|
||||
const setBillingAddressEditing = useCallback(
|
||||
( isEditing ) => {
|
||||
setEditingBillingAddress( isEditing );
|
||||
if ( typeof setEditingBillingAddress === 'function' ) {
|
||||
setEditingBillingAddress( isEditing );
|
||||
}
|
||||
},
|
||||
[ setEditingBillingAddress ]
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue