mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
Initial Axo Blocks commit
This commit is contained in:
parent
796ded031e
commit
ebd87b70e9
27 changed files with 43827 additions and 1 deletions
39
modules/ppcp-axo-block/resources/js/helpers/fieldHelpers.js
Normal file
39
modules/ppcp-axo-block/resources/js/helpers/fieldHelpers.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
export const snapshotFields = ( shippingAddress, billingAddress ) => {
|
||||
if ( ! shippingAddress || ! billingAddress ) {
|
||||
console.warn( 'Shipping or billing address is missing:', {
|
||||
shippingAddress,
|
||||
billingAddress,
|
||||
} );
|
||||
}
|
||||
|
||||
const originalData = { shippingAddress, billingAddress };
|
||||
console.log( 'Snapshot data:', originalData ); // Debug data
|
||||
localStorage.setItem(
|
||||
'originalCheckoutFields',
|
||||
JSON.stringify( originalData )
|
||||
);
|
||||
console.log( 'Original fields saved to localStorage', originalData );
|
||||
};
|
||||
|
||||
export const restoreOriginalFields = (
|
||||
updateShippingAddress,
|
||||
updateBillingAddress
|
||||
) => {
|
||||
const savedData = localStorage.getItem( 'originalCheckoutFields' );
|
||||
console.log( 'Data retrieved from localStorage:', savedData );
|
||||
|
||||
if ( savedData ) {
|
||||
const parsedData = JSON.parse( savedData );
|
||||
if ( parsedData.shippingAddress ) {
|
||||
updateShippingAddress( parsedData.shippingAddress );
|
||||
}
|
||||
if ( parsedData.billingAddress ) {
|
||||
updateBillingAddress( parsedData.billingAddress );
|
||||
}
|
||||
console.log( 'Original fields restored from localStorage', parsedData );
|
||||
} else {
|
||||
console.warn(
|
||||
'No data found in localStorage under originalCheckoutFields'
|
||||
);
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue