Created
August 14, 2022 06:35
-
-
Save encoderit-arman/d3b7a6fa07b5717aa41d2968fab76244 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
add_filter('woocommerce_cart_contents_count', 'get_total_cart_count'); | |
function get_total_cart_count($count) | |
{ | |
return count(WC()->cart->get_cart()); // easy! | |
} | |
function ajaxify_cart_count_fragments($fragments) | |
{ | |
// Turn on output buffering | |
ob_start(); | |
$items_count = count(WC()->cart->get_cart()); | |
// Content | |
echo '<span class="account-icon-box-single-shop wc-cart-item-total">' . $items_count . '</span>'; | |
// Update fragment with new content | |
$fragments['.wc-cart-item-total'] = ob_get_clean(); | |
return $fragments; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment