Eshop - How can i get items from cart on other page?

I need help. I’m building a e-shop. And in e-shop, you have a cart, where a user can add products. But if I need to get a list of items in cart to another page, for example when I want on other HTML pages do a recapitulation of order where I want to display a cart and final price. How can I do it? Thanks for any suggestions. You can see that a important part of code:

HTML (cart and first product on page):

                                    <div class="kosik-produkty">
                                    <div class="kosik-celkem">
                                        <strong class="kosik-celkem-nadpis">Celkem:</strong>
                                        <span class="kosik-celkem-cena">0,-</span><hr>
                                    <button class="button-prejit-k-vyberu-doruceni" type="button">Přejít k výběru doručení</button>

                        <div class="eshop-produkty">
                            <div class="eshop-produkt">
                                <span class="eshop-nazev-produktu"><p><strong>"18 93"</strong></p></span>
                                    <img class="eshop-fotka-produktu" src="Produkty/Samolepka_1.jpg" height='250px' width='280px'>
                                    <div class="eshop-detaily-produktu">
                                        <span class="eshop-cena-produktu">10,-</span>
                                        <button class="button-pridat-produkt-do-kosiku" type="button">Přidat do košíku</button>

Javascript (adding to cart + updating final price):

function pridejPoKliknutiDoKosiku(event) {
var button =
var produkt = button.parentElement.parentElement
var nazevProduktu = produkt.getElementsByClassName('eshop-nazev-produktu')[0].innerText
var cena = produkt.getElementsByClassName('eshop-cena-produktu')[0].innerText
var zdrojObrazku = produkt.getElementsByClassName('eshop-fotka-produktu')[0].src
pridejProduktDoKosiku(nazevProduktu, cena, zdrojObrazku)

 function pridejProduktDoKosiku(nazevProduktu, cena, zdrojObrazku) {
var radekKosik = document.createElement('div')
var kosikProdukty = document.getElementsByClassName('kosik-produkty')[0]
var NazvyProduktu = kosikProdukty.getElementsByClassName('kosik-nazev-produktu')
for (var i = 0; i < NazvyProduktu.length; i++) {
    if (NazvyProduktu[i].innerText == nazevProduktu) {
        alert("Tento produkt je již obsažen v košíku.")
var radekKosikKontent = `
        <div class="kosik-produktu kosik-sloupec">
            <img class="kosik-fotka-produktu" src="${zdrojObrazku}" width="112" height="100"><br>
            <span class="kosik-nazev-produktu">${nazevProduktu}</span>
        <span class="kosik-cena kosik-sloupec">${cena}</span>
        <div class="kosik-pocet kosik-sloupec">
            <input class="kosik-pocet-input" type="number" value="1" min="1">
            <button class="button-remove" type="button">Odstranit</button>
radekKosik.innerHTML = radekKosikKontent
radekKosik.getElementsByClassName("button-remove")[0].addEventListener('click', odstranitProduktyVKosiku)
radekKosik.getElementsByClassName('kosik-pocet-input')[0].addEventListener('change', pocetZmenen)

 function updateCelkoveCeny() {
var produktyKosikContainer = document.getElementsByClassName('kosik-produkty')[0]
var radkyKosik = produktyKosikContainer.getElementsByClassName('kosik-radek')
var celkovaCena = 0
for (var i = 0; i < radkyKosik.length; i++) {
    var radekKosik = radkyKosik[i]
    var cenaElement = radekKosik.getElementsByClassName('kosik-cena')[0]
    var pocetElement = radekKosik.getElementsByClassName('kosik-pocet-input')[0]
    var cena = parseFloat(cenaElement.innerText.replace(',-', ''))
    var pocet = pocetElement.value
    celkovaCena = celkovaCena + (cena * pocet)
document.getElementsByClassName('kosik-celkem-cena')[0].innerText = celkovaCena + ",-"

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.