• Resolved vendidero

    (@vendidero)


    Hi there,

    we develop Germanized for WooCommerce and found a strange issue with your plugin. In includes/js/checkout-fees.js L. 56-60:

    const methodSelected = $('input[name="payment_method"]:checked').val();
    	$('input[name="payment_method"]').val(${methodSelected}).trigger('change');

    Calling this code will lead to all payment method inputs to receive the currently selected payment method as input value. Luckily the payment methods will (normally) be overridden by the refreshed fragments part via AJAX but still the bug may lead to issues with other scripts (e.g. in Germanized). Could you have a look?

    Cheers

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author tychesoftwares

    (@tychesoftwares)

    Hi @vendidero,

    Oh, that’s odd. I’ll have a word with our development team and will get back to you on this.

    Thank you for bringing our notice to this.

    Plugin Author tychesoftwares

    (@tychesoftwares)

    Hi @vendidero,

    We investigated and you’re right. We are again triggering the event to get the correct value of the selected payment gateway. This might not be the best way to get payment gateway information if it’s added/removed when using some custom plugin/code.

    To understand more about the issue, it would be great if you can share more details regarding the issue you are facing in Germanized for WooCommerce with this code.

    Thread Starter vendidero

    (@vendidero)

    Hi @tychesoftwares,

    the issue is not that you are trying to trigger the event again – the issue is that you are triggering it by overriding the value attribute of all payment methods with the currently selected one. That doesn’t make any sense. Did you check that via your developer tools? If you want to trigger the change event just use:

    $('input[name="payment_method"]').trigger( 'change' ); 

    What I don’t get is why this would be even necessary? You’ve already have an event listener that listens to changes to that input field and fires the update_checkout event.

    You might reproduce the issue by adding the following snippet to your functions.php:

    add_filter( 'woocommerce_update_order_review_fragments', function( $fragments ) {
       if ( isset( $fragments['.woocommerce-checkout-payment'] ) ) {
       unset( $fragments['.woocommerce-checkout-payment'] );
    }
       return $fragments;
    }, 100 );
    Plugin Author tychesoftwares

    (@tychesoftwares)

    Hi @vendidero,

    Here is the response from the developer:

    The reason we are triggering the change event on payment selection is due to the compatibility issue with our plugin and the Country Based Payments for WooCommerce. The update_checkout was not something that can help us.

    However, we will again look at the compatibility of these two plugins to see if we can find a better way to fix it.

    We have checked by making the changes as per your suggestion. And things are working fine with it, so it will be part of the next update to the plugin.

    Hi @tychesoftwares

    Super, thanks. I hope the update then fixes the compatibility problem between both plugins.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Bug in checkout-fees.js’ is closed to new replies.