Hide free Shipping

General Marketplace Discussion (User’s interaction forum)

Hide free Shipping Open

Viewing 3 reply threads
  • Author
    Posts
    • #84355
      afieldstadium
      Participant

      Hi
      I am running a multivendor website using Wc Marketplace.

      Currently, our site has 3 vendors and each of them has their own shipping policy.

      Vendor1: Collects 2 dollar for shipping, free shipping available when customer purchase over 50 dollar

      Vendor2: collects 3 dollar for shipping, free shipping available when customer purchase over 60 dollar

      Vendor3: No shipping fee

      However I am facing free shipping problems at the moment.

      For example if customers spend more than $50 from vendor 1 and $60 from vendor 2, they will see two options:flat rate fee and free shipping.
      Thus some customer gets confused and choose flat rate fee even though they can get their order shipped free.

      Therefore I want to hide other shipping options when free shipping is available.
      As my site has multiple vendors, I want hiding other shipping options applied differently according to vendors different shipping policy.

      I have read lots of articles on this forum and tried instructions written but it did not solve my problem yet.

      <Current Status>
      1.Vendor shipping ON in admin
      2.Free shipping ON in admin(free shipping set minimum purchase price $100)
      3.Flat rate ON for each vendors(set flat rate differently from each vendors dashboard)
      4.Free Shipping ON for each vendors (set free shipping differently from each vendors dashboard)
      5.Flat rate OFF in admin

      6. Inserted Below code(child theme,functions.php)

      /**
      * Hide others shipping when free shipping is available.
      */
      function 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’, ‘hide_shipping_when_free_is_available’, 100 );

      7. Cleared woocommerce Cache

      These are my current status and it is not working yet.
      Can you guys give me hand so I can hide other shipping options when free shipping is available?

      Thank you

    • #84383

      @afieldstadium, please do use this updated code :
      /**
      * Hide others shipping when free shipping is available.
      */
      function hide_shipping_when_free_is_available( $rates ) {
      $free = array();
      foreach ( $rates as $rate_id => $rate ) {
      if ( 'Free shipping' === $rate->label ) {
      $free[ $rate_id ] = $rate;
      break;
      }
      }
      return ! empty( $free ) ? $free : $rates;
      }
      add_filter( 'woocommerce_package_rates', 'hide_shipping_when_free_is_available', 100 );

      Let us know if you need any further help.

    • #84522
      afieldstadium
      Participant

      Hi
      I used the updated code above but it does not change anything.
      I can still see flat rate and free shipping options together.
      Do you have any other solutions?

      Thanks

    • #84523

      @afieldstadium, we have checked the code on our end, it should work.

      Now as you are facing this issue, please do share a temporary admin and FTP access so we can check.

      While sharing the access, don’t forget to mark the response as private.

Viewing 3 reply threads

Please LOGIN to reply to this topic