mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
32 lines
906 B
JavaScript
32 lines
906 B
JavaScript
import { createRoot } from '@wordpress/element';
|
|
import ShippingChangeButtonManager from './ShippingChangeButtonManager';
|
|
|
|
export const injectShippingChangeButton = ( onChangeShippingAddressClick ) => {
|
|
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(
|
|
<ShippingChangeButtonManager
|
|
onChangeShippingAddressClick={ onChangeShippingAddressClick }
|
|
/>
|
|
);
|
|
} else {
|
|
console.log(
|
|
'Shipping change button already exists. Skipping injection.'
|
|
);
|
|
}
|
|
};
|
|
|
|
export const removeShippingChangeButton = () => {
|
|
const span = document.querySelector(
|
|
'#shipping-fields .wc-block-checkout-axo-block-card__edit'
|
|
);
|
|
if ( span ) {
|
|
createRoot( span ).unmount();
|
|
span.remove();
|
|
}
|
|
};
|