WooCommerce: "You have free shipping on your order!" message in cart

Here is a function to be added to the theme's functions.php file. Then it will be shown to the customer what is needed to get free shipping. You can change the amount in free if the free shipping limit should be higher or lower.

add_action( 'woocommerce_before_cart_contents', 'CartNotice_LENNARTC' );
function CartNotice_LENNARTC() {
$total = WC()->cart->total;
	$free = 249;
	$notice = '';
	if ($total < $free) {
	    $notice = sprintf(__('Buy for %s more and get free shipping', 'LENNARTC'), ''.wc_price($free - $total).'');
	} else if ($total > $free) {
		  $notice = __('You have free shipping on your order!', 'LENNARTC');
	}
	echo $notice;
}

If you want to place the text somewhere else in your cart, you can use one of these hooks instead of "woocommerce_before_cart_contents" as I use in my example:

    Useful WooCommerce Cart Hooks

  • woocommerce_before_cart_contents
  • woocommerce_after_cart_contents
  • woocommerce_before_cart_totals
  • woocommerce_cart_totals_before_shipping
  • woocommerce_after_shipping_rate
  • woocommerce_before_shipping_calculator
  • woocommerce_after_shipping_calculator
  • woocommerce_cart_totals_after_shipping
  • woocommerce_cart_totals_before_order_total
  • woocommerce_cart_totals_after_order_total
  • woocommerce_proceed_to_checkout
  • woocommerce_after_cart_totals
  • woocommerce_after_cart

There are several WooCommerce Cart hooks that you can use. However, the ones I have listed above are the ones I think are useful for the code example shown.