In the sample code, Logout doesn't actually do anything. Once a user has created a cart / order and the go to a different page, I want to force log them out, so if they go back to the cart page, it's a new order etc where they have to enter their email in again. Thanks


I'm not clear on what you're asking.

A user's cart is created as soon as they land on any page that has {% set cart = craft.commerce.cart %} in it; whether they are a logged in user or not. Carts are not attached to Users until the order is complete (and only if you were a logged in user). You can have a cart as a guest, add to it, then log in and you'll still have the same cart.

Are you saying that you want someone to fill out a cart, pay for it, complete the order - then be logged out immediately? Why? If they complete an order and then make another order it will already be a different cart.

  • That is what I had wanted, the way the site works, having a cart with multiple items wouldn't work, so they would add to the cart, pay, and then I wanted to log them out. I found a work around for this uniquely strange checkout. Although, It is something I would like to know for future reference. The cart can expire, but It would be nice to have that control, if needed.
    – SpoonShoe
    Oct 23 '16 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.