• Resolved kajalsingh98

    (@kajalsingh98)


    Hi,

    I am developing a website with embedded react. So I went on with Woocommerce Rest API and created api keys to access products, etc. But I couldnt add to cart with the default woocommerce api. Hence, I used Cocart to achieve it.
    The Flow : fetch all products with woocommerce Rest API by passing consumerkey:secret key. Similarly, add products to cart via cocart and the same headers. Now, The same cart is observed across all browsers/devices. Guest, no wplogin has been done. How do I mitigate this issue?
    I thought that the cocart cart hask/cookie is only one across the site. Hence, I added this to my functions.php file to disable it but no luck.
    add_filter( ‘cocart_cookie_supported’, function() { return false; });

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Sébastien Dumont

    (@sebd86)

    Hi @kajalsingh98

    I have a better flow for you.

    Access products via CoCart, just recently added. No authentication required so it doesn’t cause any login issues with customers. Plus product data is prepared for you so UI/UX design is easier specially for variable products.

    To continue, check out this guide on how to create a cart.

    Hope that helps.

    Thread Starter kajalsingh98

    (@kajalsingh98)

    Even if I do that, the cocart hash is domain specific and one at a time right? Wont this still cause issues such as having same cart across devices/browsers/users?

    Plugin Author Sébastien Dumont

    (@sebd86)

    If you store the cart key locally once you have it then it will be still unique per user/device/browser.

    Thread Starter kajalsingh98

    (@kajalsingh98)

    Hi Seb,

    So if I understand correctly, I will have to drop the default woo commerce API completely. Once I make the first API call via CoCart, I will have a cart key in the cookie in that response ‘X-CoCart-API’. So my question is, for each api call next, like getting products, getting current cart etc, how do I pass the cart key in each request so that the same cart is being referenced?
    Also, just a doubt. this will be completely for guest user right? Like for each call to the website via a different browser,device, the cart contents will be independent.

    Thread Starter kajalsingh98

    (@kajalsingh98)

    Also, I can’t get/access products from the normal cocart plugin :). That just makes everything then impossible isn’t it? Any other way to get products

    Plugin Author Sébastien Dumont

    (@sebd86)

    “how do I pass the cart key in each request so that the same cart is being referenced?”

    The guide I shared with you provides an example @kajalsingh98

    And yes it’s for guest customers only.

    Products is accessible with CoCart as of v3.1 wp-json/cocart/v2/products/

    Documentation is currently being updated but you can create an OPTIONS request to see the schema and arguments available for the products endpoint.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Cached Cart on all browsers/devices’ is closed to new replies.