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
|
||||
);
|
||||
|
||||
// Disable the 'Use same address for billing' checkbox
|
||||
dispatch( CHECKOUT_STORE_KEY ).__internalSetUseShippingAsBilling( false );
|
||||
const checkoutDispatch = dispatch( CHECKOUT_STORE_KEY );
|
||||
|
||||
// Disable 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;
|
||||
|
@ -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 ) => {
|
||||
if ( typeof setEditingShippingAddress === 'function' ) {
|
||||
setEditingShippingAddress( isEditing );
|
||||
}
|
||||
},
|
||||
[ setEditingShippingAddress ]
|
||||
);
|
||||
|
||||
const setBillingAddressEditing = useCallback(
|
||||
( isEditing ) => {
|
||||
if ( typeof setEditingBillingAddress === 'function' ) {
|
||||
setEditingBillingAddress( isEditing );
|
||||
}
|
||||
},
|
||||
[ setEditingBillingAddress ]
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue