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.

  • Sorry for the delay Drew, been on holiday.


    Not that i can think of, I can see Google Analytics etc using cookies.


    I haven't purchased my SSL yet, but that shouldn't stop it?

  • No i haven't set perch_ssl true or false anywhere, so it will be as default.


    A quick thought, even though the cookie isn't being set, as there is an item in the basket, shouldn't

    <?php perch_shop_cart_item_count
    (); ?>


    show 1 item?


    Or does this pull from the cookie?

  • It's really odd. there is nothing showing in local storage or session storage, and there are 4 cookies for my site:

    PHPSESSID = 2760f90c91bdd4b1c5

    _ga = GA1.2.

    _gid = GA1.2.

    cmsa = 1


    Does Perch suppress console errors? I would expect it to tell me if it tried to set a cookie and failed.


    This is happening in chrome and firefox, so can't be a browser setting. It must be something i have done in Perch or on my server...

  • So as I have now got a fresh install, i have only tried to add the basic to see if i can get this working...

    But I am still having the same issue...


    This only thing I have changed from the 'default template' is the cart url from /shop/cart to just /cart


    Do i need to update this somewhere in my perch settings? I cannot think what else could be wrong, as my server cannot block cookies, and i have tried on several browsers. I can see the url is set in PerchShop_Cart.class.php incorrectly with /shop/.. is this a problem?

  • This only thing I have changed from the 'default template' is the cart url from /shop/cart to just /cart


    The cart page URL is not significant. You can set it to whatever you need.



    I can see the url is set in PerchShop_Cart.class.php incorrectly with /shop/.. is this a problem?


    This is a path to the template (not a URL) and is also not significant to your cart page URL.



    Does Perch suppress console errors?

    It does not.




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


    I think Perch Shop automatically instantiate a new cart if the current PHP session has no cart linked to it. So this sounds like the PHP session expires prematurely and a new session is started, hence Perch Shop creating a new instance of the cart when you reload the page.


    If you turn on debug and add the following to your page, you will see the session ID in the debug message (highlighted blue):

    PHP
    1. PerchUtil::mark(session_id());


    Do you keep getting different values when you refresh the page?

  • Hi Again,


    Thank you for helping, I really appreciate it...


    I have enabled debugging but your code snippet on my cart page didn't return anything.. If I use the other debug code on cart:

    <?php PerchUtil::output_debug(); ?>


    I can see the cart id going up every time i refresh.


    SELECT * FROM perch3_shop_cart WHERE cartID=78

  • This is the debug messaging at the bottom of the page:


    If i refresh, the product stays but the cart ID increments:

    SELECT * FROM perch3_shop_cart WHERE cartID=129


    And if I navigate to /cart from this page, the page reloads empty with the next cart id:

    SELECT * FROM perch3_shop_cart WHERE cartID=130

  • Hi Hussein, Drew,


    It really saddens me to tell you this, but due to the lack of support I have had to switch from Perch to CubeCart!

    I have fallen way behind on the delivery of my website and without being able to keep a product in my basket and proceed to checkout is a huge blocker.

    I will reuse my licence for another site as I do feel Perch is a fantastic CMS, I just will not use it for any of my transactional sites.


    I would like to ask, when you start charging for support with the next version, are you going to be stepping up your support model? As I would not be happy if I had paid anymore for my license including support and this is what I received.


    All I received was questions to help identify my issue, which is completely understandable, but then silence! Not one suggestion on how to resolve.


    Like I said, I am not trying to act like a moody customer, I love Perch as a CMS, but i just feel the documentation and support is not quite there for a shop and I hope my feedback will help. Maybe Runway is better for that... and that should be the only shopping platform...

  • I've seen this happen when I was not enforcing SSL on some pages on a site. In other words, a visit to a non-ssl page would empty the cart of it's contents. So check that your all your pages are visited through SSL