mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Add address card toggling
This commit is contained in:
parent
96c566321a
commit
f77aae6b90
4 changed files with 93 additions and 5 deletions
|
@ -1,3 +1,5 @@
|
|||
import { dispatch } from '@wordpress/data';
|
||||
|
||||
export const snapshotFields = ( shippingAddress, billingAddress ) => {
|
||||
console.log( 'Attempting to snapshot fields' );
|
||||
if ( ! shippingAddress || ! billingAddress ) {
|
||||
|
@ -74,11 +76,16 @@ export const populateWooFields = (
|
|||
setWooShippingAddress,
|
||||
setWooBillingAddress
|
||||
) => {
|
||||
const CHECKOUT_STORE_KEY = 'wc/store/checkout';
|
||||
|
||||
console.log(
|
||||
'Populating WooCommerce fields with profile data:',
|
||||
profileData
|
||||
);
|
||||
|
||||
// Disable the 'Use same address for billing' checkbox
|
||||
dispatch( CHECKOUT_STORE_KEY ).__internalSetUseShippingAsBilling( false );
|
||||
|
||||
// Save shipping address
|
||||
const { address, name, phoneNumber } = profileData.shippingAddress;
|
||||
|
||||
|
@ -113,4 +120,7 @@ export const populateWooFields = (
|
|||
|
||||
console.log( 'Setting WooCommerce billing address:', billingAddress );
|
||||
setWooBillingAddress( billingAddress );
|
||||
|
||||
dispatch( CHECKOUT_STORE_KEY ).setEditingShippingAddress( false );
|
||||
dispatch( CHECKOUT_STORE_KEY ).setEditingBillingAddress( false );
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue