WooCommerce - excelling eCommerce
hiding all other shipping options and charges if a person qualifies for free shi (2 posts)

  1. Tequisitive
    Posted 1 year ago #

    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....



  2. terrytsang
    Posted 1 year ago #

    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;

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic