• Resolved javasworks

    (@javasworks)


    So, the checkout page has Cash On Delivery & Direct Bank Transfer payment method. The goal is to make to make no shipping method available or to make free shipping to be the only available method when the COD payment_method radio is checked. I need to unset jne_shipping shipping method.

    I add callback to the payment_method radio change event:

    $('input[name=payment_method]').change(function() {
      // request update_checkout to domain.com/checkout/?wc-ajax=update_order_review
      $('body').trigger('update_checkout');
    });

    and the hook in php:

    add_filter( 'woocommerce_available_shipping_methods', 'freeOnCOD', 10, 1 );
    function freeOnCOD($available_methods)
    {
        if ( isset( $_POST['payment_method'] ) && $_POST['payment_method'] === 'cod' ) {
            unset( $available_methods['jne_shipping'] );
        }
    
        return $available_methods;
    }

    But this filter hook even doesn’t run. I also try woocommerce_package_rates but still no effect.

    Ofcourse, i also checked the WooCommerce’s hooks documentation but can’t figure what is the correct hook that runs on update_checkout or update_order_review

    nyhelp appreciated

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WooCommerce's hook that runs on update_checkout or update_order_review’ is closed to new replies.