Show only free shipping in dokan

Hiding other shipping methods when FREE SHIPPING is available in Dokan Multivendor

Shipping is one of the main functionalities of any marketplace/e-commerce website. When you are selling online, you might be thinking of providing free shipping to your customer depending on their purchase amount.

This post is for those users who already have a marketplace and know how WooCommerce and Dokan shipping works. Each vendor can configure their own shipping for the zone which has been selected by the admin. They will be able to offer free shipping and Flat Shipping rate.

Analysing the problem

When a vendor is configuring their shipping they added two shipping method for the selected zone.

  1. Flat Rate – 20 USD (Ex.)
  2. Free shipping – (If purchase amount is 120 USD)

Vendor is expecting to show Flat rate only when the customer is purchasing less than 120 USD and to show only FREE SHIPPING when the order amount is 120 USD.

DARRRRNNNN!!!!!

Its not working as you are expecting. It is showing both Flat Rate and Free shipping when the order amount is 120 USD which is not a good experience for the customer.

You might have added a code snippet from WooCommerce.com documentation but that won’t work for Dokan.

How to solve?

I was thinking of a solution but could not find any. After that, I found a solution and my friend Alamgir helped me with the code.

Now, open your child-theme/functions.php file and paste the below code –

After saving the code, you will be happy, and don’t forget to subscribe to my youtube channel.

Only Free Shipping is showing

Now, only free shipping is showing when the customer is purchasing from a certain amount. This will work for multiple vendors at the same time.

If this blog was helpful then share to your social channel.

Full Video Tutorial

Share This Post

Related Post

0 thoughts on “Hiding other shipping methods when FREE SHIPPING is available in Dokan Multivendor

    1. function dokan_vendor_shipping_hide_when_free_is_available( $rates ) {
      $free = array();
      foreach ( $rates as $rate_id => $rate ) {
      if ( ‘free_shipping’ === $rate->method_id || ‘free_shipping’ === $rate->id || strpos( $rate->id, ‘free_shipping’ ) !== false ) {
      $free[ $rate_id ] = $rate;
      break;
      }
      }
      foreach ( $rates as $rate_id => $rate ) {
      if ( ‘local_pickup’ === $rate->method_id || ‘local_pickup’ === $rate->id || strpos( $rate->id, ‘local_pickup’ ) !== false ) {
      $free[ $rate_id ] = $rate;
      break;
      }
      }

      return ! empty( $free ) ? $free : $rates;
      }
      add_filter( ‘woocommerce_package_rates’, ‘dokan_vendor_shipping_hide_when_free_is_available’, 100 );

  1. Here is a scenario I cannot get my head around.

    Vendor 1 offers free shipping for all orders.
    Vendor 2 offers free shipping if minimum order is $200.

    User adds two products to the cart.

    Vendor 1
    Product 1 $150
    Free shipping

    Vendor 2
    Product 2 $75
    Shipping Cost $25

    Order Total $250
    Order Total Before Shipping Cost $225

    Since Vendor 2 offers free shipping if minimum order is $200 and order total is $225, does this mean Vendor 2 also offers free shipping? Because the criteria is met. Or, the criteria based on the order total of Vendor 2 products in the cart page?

    I appreciate your help.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: