Free shipping above fixed orders in woocommerce.


Free shipping above fixed orders in woocommerce.

Adding free shipping above specific amount of order is really cool. Customer get free shipping on particular orders, also its boost chances of more selling of products. In woo-commerce plugin, we can add free shipping on orders above fixed cart amount via plugin or code. We have an option to add free shipping or flat charges above fixed amount of orders in woo commerce.

Consider a situation where you have to provide free shipping to customer on order above 100$ or 100₹ and below that you charge 5$ or 50₹ as flat shipping charge. To complete this scenario you have to add free shipping and flat rate attribute from shipping option in woocommerce. Customer whose order above
100$ or 100₹ will get two option on checkout page to select :

  • Free shipping
  • Flat rate cart

This two option may create confusion for customer and may leave bad impression because both option can be checked (well nobody will select paid shipping if free shipping is there).

In order to fix this we have two options :

  • Install third party plugin
  • Add a simple code in functions.php file

You can choose to install plugin but if plugin is poorly coded then it may slow down your checkout page which is not recommended (specially when you taking payment from customer). Also plugins make websites slow.

In second option, all you have to do it add a simple code in your functions.php file (In your child theme). If you add code in main theme function.php file then you may loose code when theme will update.

To add code follow these simple steps :

  • Login into your WordPress dashboard.
  • Go to appearance – select theme editor – click on ‘I understand’ option in popup.
  • on left hand side and select your child theme and click on select (where it says select theme to edit).
  • On same right side bar, click on functions.php file.
Steps to add code in function.php file
  • In text editor, add below code just above the end of php tage (?>).
  • After adding the code, click on save and go back to dashboard option.
 * Hide shipping rates when free shipping is available.
 * work on WooCommerce above 2.6 Shipping Zones.
 * @param array $rates Array of rates found for the package.
 * @return array
 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;
	return ! empty( $free ) ? $free : $rates;
add_filter( 'woocommerce_package_rates', 'my_hide_shipping_when_free_is_available', 100 );
Add code in functions.php file

Now you can check your cart by adding products above your specified amount, free shipping will be automatically updated. Any questions or queries ? just comment.

Share this post

Leave a Reply

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