Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I want to clear the cart on loggout, what's the best way to do this? Something like a ClearCart() method would be great if there is something like that
I think calling RemoveAllOrderLines should do the trick https://docs.teacommerce.net/3.4.0/api/order-line/#removeallorderlines
Cheers, is there a way to get the store id from a surface controller?
I think Surface Controllers should have a CurrentPage property which gets you the current page, you should then be able to get the store from the root nodes store picker property by requesting it recursively.
var storeId = CurrentPage.GetPropertyValue<long>("store", true);
var currentOrder = TC.RemoveAllOrderLines(storeId);
Hope this helps
I just came across this while searching for a different problem.
by injecting ISessionManager _sessionManager into the surface controller.
@Matt I am assuming this is also okay for clearing the cart or is the other approach the preferred?
Great product by the way. Well done.
ClearCurrentOrder clears the current order from the session, it doesn't remove the order lines from the order. So no, it's not a suitable alternative.
Thanks for the speedy response and feedback.
Will change the approach as advised much appreciated.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted