• Resolved charlie0412

    (@charlie0412)


    Hello, I am using the following snippet to not apply taxes to different payment methods, however, when using Curcy, the snippet does not work stably, when I change between payment methods the taxes are applied sometimes yes and sometimes not, any idea?

    add_action( 'woocommerce_before_calculate_totals', 'change_tax_class_based_on_payment_method', 10, 1 );
    function change_tax_class_based_on_payment_method( $cart ) {
        // Only for a specific defined payment meyhod
        if ( WC()->session->get('chosen_payment_method') !== 'cod' && WC()->session->get('chosen_payment_method') !== 'cheque' && WC()->session->get('chosen_payment_method') !== 'stripe_cc')
            return;
    
        if ( is_admin() && ! defined( 'DOING_AJAX' ) )
            return;
    
        if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
            return;
    
        // Loop through cart items
        foreach( $cart->get_cart() as $cart_item ){
            // We set "Zero rate" tax class
            $cart_item['data']->set_tax_class("Zero rate");
        }
    }
    
    add_action('wp_footer', 'payment_methods_trigger_update_checkout');
    function payment_methods_trigger_update_checkout() {
        if( is_checkout() && ! is_wc_endpoint_url() ) :
        ?>
        <script type="text/javascript">
            jQuery(function($){
                $( 'form.checkout' ).on('change', 'input[name="payment_method"]', function() {
                    $(document.body).trigger('update_checkout');
                });
            });
        </script>
        <?php
        endif;
    }
Viewing 1 replies (of 1 total)
  • Plugin Support angelagrey

    (@angelagrey)

    Hi,

    Thank you for reaching out to us.

    Regarding custom snippets, we’re unable to provide support, and any instability when using Curcy with custom code is beyond our current scope. For stability concerns, we suggest reviewing and testing the snippet independently.

    Should you have queries about Curcy’s standard features, feel free to ask.

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘Snippet issue with curcy’ is closed to new replies.