Created
July 20, 2023 12:30
-
-
Save andxbes/e22716d7bdc9a8bb7e89e03d5c57a6fc to your computer and use it in GitHub Desktop.
Woo update cart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('woocommerce_add_to_cart_fragments', function($fragments){ | |
$count = WC()->cart->get_cart_contents_count(); | |
ob_start(); ?> | |
<span class="cart-value" <?php echo ($count == 0) ? 'style="display:none;"' : ''; ?>><?php echo $count ?></span> | |
<?php $fragments['span.cart-value'] = ob_get_clean(); | |
return $fragments; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment