function displayCart() {
        let cartItems = localStorage.getItem("productsInCart");
        cartItems = JSON.parse(cartItems);
        let productContainer = document.querySelector(".b-cart-content__products");
        let cartCost = localStorage.getItem("totalCost");

        if(cartItems && productContainer) {
            productContainer.innerHTML = '';
            Object.values(cartItems).forEach(item => {
                productContainer.innerHTML += `
                    <div class="b-cart-content__products-product">
                        <div class="b-cart-content__products-product__image">
                            <img src="../../images/${item.image}" />
                            <div class="b-cart-content__products-product__image-name">
                                <p>${item.name}</p>
                            </div>
                        </div>
                        <div class="b-cart-content__products-product__price">
                            <span>R$${item.bestPrice}</span>
                        </div>
                        <div class="b-cart-content__products-product__quantity">
                            <span class="decrease">-</span>
                            <span>${item.inCart}</span>
                            <span class="increase">+</span>
                        </div>
                        <div class="b-cart-content__products-product__total">
                            <span>R$${item.inCart * item.bestPrice}</span>
                        </div>
                    </div>
                `;
            });

            productContainer.innerHTML += `
                <div class="b-cart-content__products-summary">
                    <div class="b-cart-content__products-summary__text">
                        <p>Agradecemos a sua preferência.</p>
                    </div>
                    <div class="b-cart-content__products-summary__finally">
                        <button type="submit">Finalizar</button>
                    </div>
                    <div class="b-cart-content__products-summary__subtotal">
                        <h3 class="summary-title">Total</h3>
                        <h3 class="summary-subtotal">R$<span>${cartCost}</span></h3>
                    </div>
                </div>
            `;
        }
    }
//Function to display products in cart page
Function to display products in cart page
Function to display products in cart page
function displayCart() {
        let cartItems = localStorage.getItem("productsInCart");
        cartItems = JSON.parse(cartItems);
        let productContainer = document.querySelector(".b-cart-content__products");
        let cartCost = localStorage.getItem("totalCost");
        if(cartItems && productContainer) {
            productContainer.innerHTML = '';
            Object.values(cartItems).forEach(item => {
                productContainer.innerHTML += `
                    <div class="b-cart-content__products-product">
                        <div class="b-cart-content__products-product__image">
                            <img src="../../images/${item.image}" />
                            <div class="b-cart-content__products-product__image-name">
                                <p>${item.name}</p>
                            </div>
                        </div>
                        <div class="b-cart-content__products-product__price">
                            <span>R$${item.bestPrice}</span>
                        </div>
                        <div class="b-cart-content__products-product__quantity">
                            <span class="decrease">-</span>
                            <span>${item.inCart}</span>
                            <span class="increase">+</span>
                        </div>
                        <div class="b-cart-content__products-product__total">
                            <span>R$${item.inCart * item.bestPrice}</span>
                        </div>
                    </div>
                `;
            });
            productContainer.innerHTML += `
                <div class="b-cart-content__products-summary">
                    <div class="b-cart-content__products-summary__text">
                        <p>Agradecemos a sua preferência.</p>
                    </div>
                    <div class="b-cart-content__products-summary__finally">
                        <button type="submit">Finalizar</button>
                    </div>
                    <div class="b-cart-content__products-summary__subtotal">
                        <h3 class="summary-title">Total</h3>
                        <h3 class="summary-subtotal">R$<span>${cartCost}</span></h3>
                    </div>
                </div>
            `;
        }
    }
function displayCart ( ) { let cartItems = localStorage . getItem ( "productsInCart" ) ; cartItems = JSON . parse ( cartItems ) ; let productContainer = document . querySelector ( ".b-cart-content__products" ) ; let cartCost = localStorage . getItem ( "totalCost" ) ; if ( cartItems && productContainer ) { productContainer . innerHTML = '' ; Object . values ( cartItems ) . forEach ( item => { productContainer . innerHTML += ` ${ item . image } ${ item . name } ${ item . bestPrice } ${ item . inCart } ${ item . inCart * item . bestPrice } ` ; } ) ; productContainer . innerHTML += ` ${ cartCost } ` ; } }
Function to display products in cart page
Function to display products in cart page