How to Add Store Notices in Woocommerce

Custom notifications for customers can be a handy tool to create more sales or increase the average order total.

For example, let’s say a store has Free Shipping on orders of $100 or more. If a customer has $90 of products in their cart, notifying them that they are $10 away from Free Shipping is useful to the customer and to the store owner.

Most customers will buy an extra item to get past the $100 threshold just to save a couple bucks on shipping. So here i can acheive this by following code. Just copy this code and paste this code at the end of your theme’s functions.php file of your active child theme (or theme) and Save the file.

     function custom_notice_free_shipping() {
	if ( ! is_cart() ) {
		return;
	}
	$subtotal = WC()->cart->cart_contents_total + WC()->cart->get_taxes_total( false, false );
	$free_shipping_threshold = 100;
	if ( $subtotal < $free_shipping_threshold && $subtotal > ( $free_shipping_threshold / 2 ) ) {
		wc_add_notice( 'Orders above $100 get free shipping', 'notice' );
	}
   }
   add_action( 'wp', 'custom_notice_free_shipping' );

Leave a Comment

Scroll to Top