mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Add better state management utilizing Redux
This commit is contained in:
parent
db449b5d70
commit
bccfe4c436
11 changed files with 432 additions and 172 deletions
|
@ -56,13 +56,24 @@ const ShippingChangeButtonManager = ( { onChangeShippingAddressClick } ) => {
|
|||
};
|
||||
|
||||
export const injectShippingChangeButton = ( onChangeShippingAddressClick ) => {
|
||||
const container = document.createElement( 'div' );
|
||||
document.body.appendChild( container );
|
||||
createRoot( container ).render(
|
||||
createElement( ShippingChangeButtonManager, {
|
||||
onChangeShippingAddressClick,
|
||||
} )
|
||||
// Check if the button already exists
|
||||
const existingButton = document.querySelector(
|
||||
'#shipping-fields .wc-block-checkout-axo-block-card__edit'
|
||||
);
|
||||
|
||||
if ( ! existingButton ) {
|
||||
const container = document.createElement( 'div' );
|
||||
document.body.appendChild( container );
|
||||
createRoot( container ).render(
|
||||
createElement( ShippingChangeButtonManager, {
|
||||
onChangeShippingAddressClick,
|
||||
} )
|
||||
);
|
||||
} else {
|
||||
console.log(
|
||||
'Shipping change button already exists. Skipping injection.'
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const removeShippingChangeButton = () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue