mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Add backwards compatibility when address editing state toggling is not available
This commit is contained in:
parent
75960fc4a4
commit
47ceb8333b
2 changed files with 23 additions and 6 deletions
|
@ -83,8 +83,14 @@ export const populateWooFields = (
|
||||||
profileData
|
profileData
|
||||||
);
|
);
|
||||||
|
|
||||||
// Disable the 'Use same address for billing' checkbox
|
const checkoutDispatch = dispatch( CHECKOUT_STORE_KEY );
|
||||||
dispatch( CHECKOUT_STORE_KEY ).__internalSetUseShippingAsBilling( false );
|
|
||||||
|
// Disable the 'Use same address for billing' checkbox if the method exists.
|
||||||
|
if (
|
||||||
|
typeof checkoutDispatch.__internalSetUseShippingAsBilling === 'function'
|
||||||
|
) {
|
||||||
|
checkoutDispatch.__internalSetUseShippingAsBilling( false );
|
||||||
|
}
|
||||||
|
|
||||||
// Save shipping address
|
// Save shipping address
|
||||||
const { address, name, phoneNumber } = profileData.shippingAddress;
|
const { address, name, phoneNumber } = profileData.shippingAddress;
|
||||||
|
@ -121,6 +127,13 @@ export const populateWooFields = (
|
||||||
console.log( 'Setting WooCommerce billing address:', billingAddress );
|
console.log( 'Setting WooCommerce billing address:', billingAddress );
|
||||||
setWooBillingAddress( billingAddress );
|
setWooBillingAddress( billingAddress );
|
||||||
|
|
||||||
dispatch( CHECKOUT_STORE_KEY ).setEditingShippingAddress( false );
|
// Collapse shipping address input fields into the card view.
|
||||||
dispatch( CHECKOUT_STORE_KEY ).setEditingBillingAddress( false );
|
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(
|
const setShippingAddressEditing = useCallback(
|
||||||
( isEditing ) => {
|
( isEditing ) => {
|
||||||
setEditingShippingAddress( isEditing );
|
if ( typeof setEditingShippingAddress === 'function' ) {
|
||||||
|
setEditingShippingAddress( isEditing );
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[ setEditingShippingAddress ]
|
[ setEditingShippingAddress ]
|
||||||
);
|
);
|
||||||
|
|
||||||
const setBillingAddressEditing = useCallback(
|
const setBillingAddressEditing = useCallback(
|
||||||
( isEditing ) => {
|
( isEditing ) => {
|
||||||
setEditingBillingAddress( isEditing );
|
if ( typeof setEditingBillingAddress === 'function' ) {
|
||||||
|
setEditingBillingAddress( isEditing );
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[ setEditingBillingAddress ]
|
[ setEditingBillingAddress ]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue