Skip to main content
WoocommerceWordpress

Increase your ecommerce average order by adding a notice with the missing amount until you get free shipping

By July 1, 2021No Comments

In this post we tell you how to increase the average order of your cart in Woocommerce.
We know that this is not an easy task, but we will show you how this small step will contribute to this goal.

In the majority of studies carried out, measuring the main reasons for abandonment of carts in online stores, the cost of shipping is usually the first reasons for abandonment of the purchase. And in most cases, this occurs because the shipping costs are not clear from the beginning, many users are surprised in the last phase of purchase.

Free shipping over the amount is a really effective marketing strategy in eCommerce.

Most clients would be willing to buy something extra from your store than paying for delivery

We know that Woocommerce is one of the best tools to sell on the Internet, but it does not come with the possibility of adding a notice that says how much is left for free shipping out of the box. This notice, as simple as it sounds can really help increase the average cart price.

How to display remaining amount to free shipping in WooCommerce?

/* Code for displaying amount Left for Free Shipping on Cart and Checkout by ATW*/
function atw_free_shipping_notice() {	// In this case we made a function for both, Cart and Checkout, but it can be done for just one of them.	if ( ! is_cart() && ! is_checkout() ) { 
		  return;
	  }	  $packages = WC()->cart->get_shipping_packages();
	  $package = reset( $packages );
	  $zone = wc_get_shipping_zone( $package );
	  $cart_total = WC()->cart->get_displayed_subtotal();	  if ( WC()->cart->display_prices_including_tax() ) {
		  $cart_total = round( $cart_total - ( WC()->cart->get_discount_total() + WC()->cart->get_discount_tax() ), wc_get_price_decimals() );
	  } else {
		  $cart_total = round( $cart_total - WC()->cart->get_discount_total(), wc_get_price_decimals() );
	  }
	  foreach ( $zone->get_shipping_methods( true ) as $k => $method ) {
		  $min_amount = $method->get_option( 'min_amount' );
		  if ( $method->id == 'free_shipping' && ! empty( $min_amount ) && $cart_total < $min_amount ) {
			  $remaining = $min_amount - $cart_total;					// Text that will be displayed on cart and checkout :)
			  wc_add_notice( sprintf( 'Spend %s more to get free shipping', wc_price( $remaining ) ) );
		  }
	  }
  }
  add_action( 'wp', 'atw_free_shipping_notice' );

Things to consider:

  • The code currently works with the latest version of WordPress (5.7.2) and WooCoommerce (3.7.0) to date.
  • The minimum amount for the free order must be previously configured in WooCoommerce.
  • You can style the notice with CSS

You’re more than welcome to just contact us directly to implement this cool feature!

Contact us to learn more about Adopt the Web for your business

Author Guido Magaldi

Guido is a professional front end developer. He loves creating and developing dream websites for our clients. When he is not at the computer working on awesome website design, he is kitesurfing the glacial waters of Bariloche .

More posts by Guido Magaldi