mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Initial Axo Blocks commit
This commit is contained in:
parent
796ded031e
commit
ebd87b70e9
27 changed files with 43827 additions and 1 deletions
33
modules/ppcp-axo-block/resources/js/helpers/buttonHelpers.js
Normal file
33
modules/ppcp-axo-block/resources/js/helpers/buttonHelpers.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
export const injectShippingChangeButton = ( onChangeShippingAddressClick ) => {
|
||||
const shippingTitle = document.querySelector(
|
||||
'#shipping-fields h2.wc-block-components-title'
|
||||
);
|
||||
if (
|
||||
shippingTitle &&
|
||||
! shippingTitle.nextElementSibling?.classList?.contains(
|
||||
'wc-block-checkout-axo-block-card__edit'
|
||||
)
|
||||
) {
|
||||
const buttonElement = document.createElement( 'button' );
|
||||
buttonElement.classList.add( 'wc-block-checkout-axo-block-card__edit' );
|
||||
buttonElement.setAttribute( 'aria-label', 'Change shipping details' );
|
||||
buttonElement.textContent = 'Change';
|
||||
buttonElement.onclick = ( event ) => {
|
||||
event.preventDefault();
|
||||
onChangeShippingAddressClick();
|
||||
};
|
||||
shippingTitle.parentNode.insertBefore(
|
||||
buttonElement,
|
||||
shippingTitle.nextSibling
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const removeShippingChangeButton = () => {
|
||||
const existingButton = document.querySelector(
|
||||
'#shipping-fields .wc-block-checkout-axo-block-card__edit'
|
||||
);
|
||||
if ( existingButton ) {
|
||||
existingButton.remove();
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue