Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save balwantmeticulosity/213d8e250b151d2e8c7ef6bc9ce7e573 to your computer and use it in GitHub Desktop.

Select an option

Save balwantmeticulosity/213d8e250b151d2e8c7ef6bc9ce7e573 to your computer and use it in GitHub Desktop.
Woocommerce update minicart
add_filter( 'woocommerce_add_to_cart_fragments', 'wc_refresh_mini_cart_count');
function wc_refresh_mini_cart_count($fragments){
ob_start();
?>
<span class="cart-no mini-cart-count">
<?php echo WC()->cart->get_cart_contents_count(); ?>
</span>
<?php
$fragments['.mini-cart-count'] = ob_get_clean();
return $fragments;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment