After a deep search I created a WooCommerce shortcode. The purpose of this is to display a "Buy X more products to get a discount" message.
My code:
add_shortcode('check', 'custommessage');
function custommessage() {
$items_count = WC()->cart->get_cart_contents_count();
$min_count = 6;
if( $items_count < $min_count ){
echo sprintf('%s products more for discount' , $min_count - $items_count );
}
}
On WooComerce cart page, after adding X products to the cart or removing the quantity it works and refreshes automatically the message
But when I put the shortcode (on side cart) it does not auto refresh the X count. Although it is also AJAX driven.
Any advice how i can solve this?