I have set a threshold of 3 items for someone in the UK to get Free Shipping. Every time someone adds a product from a specific category, I automatically add a product to their cart which is a free gift.
My issue is that I am trying to exclude this free gift from the threshold count as currently this is being counted and people are getting free shipping without having 3 actual chargeable items in their cart.
I am unsure to how I can exclude product id 29 from counting, so any help would be greatly appreciated.
add_action( 'woocommerce_before_cart', 'ds_free_shipping_cart_notice' );
function ds_free_shipping_cart_notice() {
$threshold = 3;
$current = WC()->cart->get_cart_contents_count();
$billing_country = WC()->customer->get_billing_country();
if ( $current < $threshold && WC()->customer->get_billing_country() == 'GB' ) {
wc_print_notice( 'Nearly there! Order ' . ( $threshold - $current ) . ' more and shipping is on us', 'notice' );
}
}