sinanisler logo

Mini Cart Count, Only Show Unique Product Count, WooCommerce

Mini Cart Count, Only Show Unique Product Count instead of total number of multiple buy count. WooCommerce

add this to footer

there is one known but when cart gets updated the count goes back to the total number of product again. I may update this snippet later on…


document.addEventListener('DOMContentLoaded', function () {
    // Function to update and log cart count
    function updateCartCount() {
        var cartCountElement = document.querySelector('.cart-count');
        var miniCartItems = document.querySelectorAll('.mini_cart_item');
        var itemCount = miniCartItems.length;

        if (cartCountElement) {
            cartCountElement.textContent = itemCount;
            console.log('Cart Count: ' + itemCount);

    var observer = new MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
            if (mutation.type === 'childList') {

    var config = { childList: true, subtree: true };
    var cartContainer = document.querySelector('.your-cart-container-class');
    if (cartContainer) {
        observer.observe(cartContainer, config);

    // Delay initial update
    setTimeout(updateCartCount, 1000); // Adjust the delay as needed


Recently made this code for the WooCommerce site for our agency geopard digital client.

Leave the first comment