Cart won't persist, and seems to be on a different url

  • Good Evening,


    I am sorry (Drew) for all the forum posts, I believe this is my last issue now.


    So on my product page, I have a product with a few different variants, and an add to cart button. I think it is pretty much the out of the box template, although i changed the url from '/shop/cart' to just '/cart':


    When i make my selection, and click add to cart, i am taken to the cart page (/cart), and the item is displayed. However, the basket link in my header still shows 0 items, using this code:

    PHP
    1. <?php perch_shop_cart_item_count(); ?>


    But the biggest issue is that if I refresh the page, the item will stay there, but if I leave and come back, or click the basket link in my header:

    PHP
    1. <a href="/cart">
    2. <i class="material-icons">shopping_cart</i>
    3. <?php perch_content('Header Basket Text'); ?>
    4. <span><?php perch_shop_cart_item_count(); ?></span>
    5. </a>

    The page loads with a 'basket empty' message.


    I haven't strayed too far from the docs, so not sure what I could have implemented incorrectly?


    Thank you in advance,

    Sam

  • Just to add, I think it has something to do with the cart number which keeps increasing!


    I have added debug info to the bottom of the cart page...


    When I add to basket, i get this info:


    Then when i click the basket link which should link to and basically refresh the same page I am on I get this info:


    It seems it has auto-incremented the basket ID... Do I need to set a cookie?

  • Hi Drew,


    Here is my diagnostics report:

  • Good evening Drew,


    Sure, my cart is simply my site header, then my body containing this:

    PHP
    1. <section class="main-content cart">
    2. <?php perch_shop_cart(); ?>
    3. </section>


    Then my footer.