Cart, Checkout, Product Archive, Product Page

WooCommerce Cart Total Based Banner

WooCommerce Banner showing when cart total reaches certain threshold amount

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

This guide shows you how you how to show a banner on your WooCommerce site based on the cart total. In our example, we show a banner letting the customer know their cart total is over 2K therefore qualifying for free shipping. This guide be used to show any banner message you like whether it’s shipping related or not. Simply change the threshold to your desired amount as well as the message and formatting of the banner as necessary.

/**
 * Snippet Name:	WooCommerce Banner Based On Cart Total
 * Snippet Author:	ecommercehints.com
 */

add_action( 'wp_head', 'ecommercehints_cart_total_based_banner' );
function ecommercehints_cart_total_based_banner() {
$order_total = WC()->cart->subtotal;
if ( $order_total > 2000 ) { // The threshold for the banner to appear ?>
<style>
	.ecommercehints_category_banner {
		background-color: blue;
		color: white;
		font-size:20px;
		text-align:center;
	}
</style>
<?php echo '<div class="ecommercehints_cart_total_based_banner">Your order is over 2K, you qualify for free shipping!</div>';
}
}

Snippet Benefits

  • Show a banner on your WooCommerce website based on the customer’s cart total.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.

26027
WELCOME OFFER