function displayMinicart() {
        let cartItems = localStorage.getItem("productsInCart");
        cartItems = JSON.parse(cartItems);
        let minicartContainer = document.querySelector(".b-header-container__minicart-content__products-content");
        let cartCost = localStorage.getItem("totalCost");

        if(cartItems && minicartContainer) {
            minicartContainer.innerHTML = '';

            Object.values(cartItems).forEach(product => {
                minicartContainer.innerHTML += `
                <div class="b-header-container__minicart-content__products-content__item">
                    <div class="b-header-container__minicart-content__products-content__item-image">
                        <img src="../../images/${product.image}" />
                    </div>
                    <div class="b-header-container__minicart-content__products-content__item-name">
                        <h4>${product.name}</h4>
                    </div>
                    <div class="b-header-container__minicart-content__products-content__item-price">
                        <h4>${product.bestPrice}</h4>
                    </div>
                </div>
                `;
            });

            document.querySelector(".b-header-container__minicart-content__cost-price span").textContent = cartCost;
            localStorage.setItem("productsInMinicart", minicartContainer.innerHTML);
        }
    }
//Function to display products in minicart
Function to display products in minicart
Function to display products in minicart
function displayMinicart() {
        let cartItems = localStorage.getItem("productsInCart");
        cartItems = JSON.parse(cartItems);
        let minicartContainer = document.querySelector(".b-header-container__minicart-content__products-content");
        let cartCost = localStorage.getItem("totalCost");
        if(cartItems && minicartContainer) {
            minicartContainer.innerHTML = '';
            Object.values(cartItems).forEach(product => {
                minicartContainer.innerHTML += `
                <div class="b-header-container__minicart-content__products-content__item">
                    <div class="b-header-container__minicart-content__products-content__item-image">
                        <img src="../../images/${product.image}" />
                    </div>
                    <div class="b-header-container__minicart-content__products-content__item-name">
                        <h4>${product.name}</h4>
                    </div>
                    <div class="b-header-container__minicart-content__products-content__item-price">
                        <h4>${product.bestPrice}</h4>
                    </div>
                </div>
                `;
            });
            document.querySelector(".b-header-container__minicart-content__cost-price span").textContent = cartCost;
            localStorage.setItem("productsInMinicart", minicartContainer.innerHTML);
        }
    }
function displayMinicart ( ) { let cartItems = localStorage . getItem ( "productsInCart" ) ; cartItems = JSON . parse ( cartItems ) ; let minicartContainer = document . querySelector ( ".b-header-container__minicart-content__products-content" ) ; let cartCost = localStorage . getItem ( "totalCost" ) ; if ( cartItems && minicartContainer ) { minicartContainer . innerHTML = '' ; Object . values ( cartItems ) . forEach ( product => { minicartContainer . innerHTML += ` ${ product . image } ${ product . name } ${ product . bestPrice } ` ; } ) ; document . querySelector ( ".b-header-container__minicart-content__cost-price span" ) . textContent = cartCost ; localStorage . setItem ( "productsInMinicart" , minicartContainer . innerHTML ) ; } }
Function to display products in minicart
Function to display products in minicart