• Resolved evalast

    (@evalast)


    Above a certain value the customer gets free delivery. In this case, the other delivery cost options are hidden with the following code. However, the subtotal row in the cart and checkout is also redundant, any idea how to hide it?

    `// Hide ALL shipping rates in ALL zones when Free Shipping is available
    add_filter( ‘woocommerce_package_rates’, ‘bbloomer_unset_shipping_when_free_is_available_all_zones’, 10, 2 );
    function bbloomer_unset_shipping_when_free_is_available_all_zones( $rates, $package ) {

    $all_free_rates = array();

    foreach ( $rates as $rate_id => $rate ) {
    if ( ‘free_shipping’ === $rate->method_id ) {
    $all_free_rates[ $rate_id ] = $rate;
    break;
    }
    }

    if ( empty( $all_free_rates )) {
    return $rates;
    } else {
    return $all_free_rates;
    }

    }

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to Hide Cart Subtotal Row In WooCommerce if Free Shipping is set’ is closed to new replies.