Hi guys,
You provided me with the following code to hide the cart item count if the cart was empty.
function woodmart_cart_count() {
if ( ! is_object( WC() ) || ! property_exists( WC(), ‘cart’ ) || ! is_object( WC()->cart ) || !
method_exists( WC()->cart, ‘get_cart_contents_count’ ) || WC()->cart->cart_contents_count == 0 ) {
return;
}
$count = WC()->cart->get_cart_contents_count();
?>
<span class=”wd-cart-number wd-tools-count<?php echo woodmart_get_old_classes( ‘ woodmart-cart-number’ ); ?>”><?php echo esc_html( $count ); ?> <span><?php echo esc_html( _n( ‘item’, ‘items’, $count, ‘woodmart’ ) ); ?></span></span>
<?php
}
The only issue is that after adding an item to the cart you have to refresh the page for the item count to appear, please can you help me fix this?
Thanks in advance.