• Hello,

    A Cocart Pro user here.

    I’m trying to clear the cart after a successful order, I’m calling this endpoint: /wp-json/cocart/v2/cart/clear in the response it shows an empty cart, but when I fire a get request for with the same user I got the same cart as before. What could be the issue here?

    thanks!

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

    (@sebd86)

    Was the cart authorized or a guest session?

    Thread Starter svr101

    (@svr101)

    It was authorized.

    Plugin Author Sébastien Dumont

    (@sebd86)

    OK. Will check if we can replicate the issue.

    Thread Starter svr101

    (@svr101)

    Thanks!

    I’m using this -> https://simplejwtlogin.com/ for the JWT and Nextjs 13 as my frontend.

    Let me know if you need any more info.

    Plugin Author Sébastien Dumont

    (@sebd86)

    It’s most likely compatibility then. Please try CoCart’s own JWT authentication instead with CoCart and see if the issue is the same.

    Thread Starter svr101

    (@svr101)

    Will this work with the rest of the WC routes or only with the CoCart ones?

    Thanks for the tipp, will try it on the weekend.

    Plugin Author Sébastien Dumont

    (@sebd86)

    It’s developed for just CoCart.

    Thread Starter svr101

    (@svr101)

    That’s not ideal, using 2 jwt solutions for one site (I need to get other data that is not coming from CoCart)

    So I did some testing.

    If I use Insomnia with my custom header AND ‘Authorization’ the cart gets cleared fine, but when I do it from nextjs it did not…

    Both using “Bearer {token}” as value

    Plugin Author Sébastien Dumont

    (@sebd86)

    The JWT for CoCart is unique for customer identification. It’s not a standard JWT for back-end purposes that the other JWT plugins do.

    If it works in Insomnai then check the headers are getting passed correctly in your code. I find not doing the headers correctly causes the most simple issues that should not be a problem to begin with.

    The plugin does work as it should.

    I’m curious as to what custom header your referring too?

    Thread Starter svr101

    (@svr101)

    custom header: The JWT plugin let’s me define what header name I want to use as auth header. I use X-{sitename}-Auth.

    That’s the thing. It works as it should, but the clear cart endpoint.

    (I’m using: get cart, add item to cart, remove item, calculate shipping, set shipping methods, check coupon, apply coupon)

    That’s why I’m asking what might be the issue

    Plugin Author Sébastien Dumont

    (@sebd86)

    With CoCart we only support standard Authentication header. A filter can be added to change this if you like?

    Plugin Author Sébastien Dumont

    (@sebd86)

    I have added a filter for the authentication header and will be supported in the upcoming v4 of CoCart.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Can’t clear cart for logged in user’ is closed to new replies.