• hlynur

    (@hlynur)


    Hi

    I need help with Woocommerce shipping options. The store sends free shipping if the amount exceeds 8500 ISK, otherwise shipping costs 1500 ISK.

    My problem is that I can make the free shipping option appear when the amount is over 8500 but the other shipping option (pay 1500) is still there.

    Can anyone tell me how I can make that shipping option disappear when the customer buys for more than 8500?.

Viewing 1 replies (of 1 total)
  • carver1g

    (@carver1g)

    I use a child theme and use this code in the child’s theme functions.php file:

    /*Hide shipping rates when free shipping is available*/
    function my_hide_shipping_when_free_is_available( $rates ) {
    $free = array();
    foreach ( $rates as $rate_id => $rate ) {
    if ( ‘free_shipping’ === $rate->method_id ) {
    $free[ $rate_id ] = $rate;
    break;
    }
    }
    return ! empty( $free ) ? $free : $rates;
    }
    add_filter( ‘woocommerce_package_rates’, ‘my_hide_shipping_when_free_is_available’, 100 );

    Hope this is what you were looking for.

Viewing 1 replies (of 1 total)
  • The topic ‘Free shipping if price exceeds x amount’ is closed to new replies.