Support » Plugin: WooCommerce » hiding all other shipping options and charges if a person qualifies for free shi

  • i have three methods of shipping on my website
    international shipping is setup correctly

    I setup free shipping for orders above rs 500.
    i wanna setup another shipping method, which will be visible for only orders below 500,, any suggestions,,??

    presently i am using flat rate shipping.. BUT it keeps showing even on orders above 500….

    PLEASE HELP

    https://wordpress.org/plugins/woocommerce/

Viewing 1 replies (of 1 total)
  • Hi @tequisitive, if you use both flat rate (< rs 500) and free shipping(>= rs 500), then you can put below code in your theme functions.php:

    add_filter( 'woocommerce_package_rates', 'hide_others_when_free_shipping_available', 10, 2 );
    
    function hide_others_when_free_shipping_available( $rates, $package ) {
      if ( isset( $rates['free_shipping'] ) ) {
        unset( $rates['flat_rate'] ); //unset flat_rate shipping id
    
        $free_shipping = $rates['free_shipping'];
        $rates = array();
        $rates['free_shipping'] = $free_shipping;
      }
      return $rates;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘hiding all other shipping options and charges if a person qualifies for free shi’ is closed to new replies.