mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Wrapper the button toggle functionality and use that instead of relying of events
This commit is contained in:
parent
88e723bda5
commit
986cec7fef
1 changed files with 12 additions and 10 deletions
|
@ -11,15 +11,7 @@ class CheckoutBootstap {
|
|||
}
|
||||
|
||||
const renderer = new Renderer(PayPalCommerceGateway.button.wrapper);
|
||||
|
||||
jQuery(document.body).on('updated_checkout', () => {
|
||||
renderer.render(this.configurator.configuration());
|
||||
|
||||
jQuery(document.body).trigger('payment_method_selected');
|
||||
});
|
||||
|
||||
jQuery(document.body).on('payment_method_selected', () => {
|
||||
// TODO: replace this dirty check, possible create a separate
|
||||
const toggleButtons = () => {
|
||||
const currentPaymentMethod = jQuery(
|
||||
'input[name="payment_method"]:checked').val();
|
||||
|
||||
|
@ -31,13 +23,23 @@ class CheckoutBootstap {
|
|||
renderer.showButtons();
|
||||
jQuery('#place_order').hide();
|
||||
}
|
||||
};
|
||||
|
||||
jQuery(document.body).on('updated_checkout', () => {
|
||||
renderer.render(this.configurator.configuration());
|
||||
toggleButtons();
|
||||
});
|
||||
|
||||
jQuery(document.body).on('payment_method_selected', () => {
|
||||
toggleButtons();
|
||||
});
|
||||
|
||||
renderer.render(this.configurator.configuration());
|
||||
}
|
||||
|
||||
shouldRender() {
|
||||
if (document.querySelector(PayPalCommerceGateway.button.cancel_wrapper)) {
|
||||
if (document.querySelector(
|
||||
PayPalCommerceGateway.button.cancel_wrapper)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue