Tell shoppers exactly how much more they need to spend to get free shipping, right in the cart and at checkout.
add_action( 'woocommerce_before_cart', 'nahnu_free_shipping_notice' );
add_action( 'woocommerce_before_checkout_form', 'nahnu_free_shipping_notice' );
function nahnu_free_shipping_notice(): void {
$threshold = 75.00; // Match the minimum on your Free shipping method.
$subtotal = (float) WC()->cart->get_displayed_subtotal();
$remaining = $threshold - $subtotal;
if ( $remaining > 0 ) {
wc_print_notice(
sprintf( 'Add %s more to get free shipping.', wc_price( $remaining ) ),
'notice'
);
}
}
Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.
A free shipping threshold only works if shoppers know how close they are. This snippet shows a notice in the cart and at checkout with the exact amount left to spend.
The function runs on woocommerce_before_cart and woocommerce_before_checkout_form. It compares the cart subtotal, as displayed to the customer including or excluding tax to match your settings, with your threshold, and prints a standard WooCommerce notice with the difference formatted in your store currency.
Once the cart reaches the threshold the notice disappears.
$threshold to the same minimum as your Free shipping method under WooCommerce → Settings → Shipping. The snippet doesn’t read it automatically, because each shipping zone can have its own.Add an item worth less than the threshold to the cart. The notice should show the difference. Add more until you pass it, and the notice should go away.