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.
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

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

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers