I have a requirement to limit the purchase of certain items to 1. I have stopped the quantity being changed while adding to the basket, but if the same product is added again, it is combined with the previous product and the quantity changes to 2.
I either need to stop the second (exact same) item being added to the basket, or allow it to be added but as a separate order line.
Adding it as a separate line in the basket would, I think, be preferable - but is it possible?
Do not combine the same product in basket
I have a requirement to limit the purchase of certain items to 1. I have stopped the quantity being changed while adding to the basket, but if the same product is added again, it is combined with the previous product and the quantity changes to 2.
I either need to stop the second (exact same) item being added to the basket, or allow it to be added but as a separate order line.
Adding it as a separate line in the basket would, I think, be preferable - but is it possible?
Hi Gordon,
Depending on how important it is to enforce the 1 item policy you should either:
Do it on the server Add a custom property to the order line, so you can identify it and then clean up the order everytime it updates. https://docs.teacommerce.net/v3.0.0/reference#notificationcenter
Use overwriteQuantity This forces the server to overwrite the quantity each time you add to the basket. It's not as secure because anyone can use the TC javascript api to do something else. https://docs.teacommerce.net/v3.0.0/reference#addorupdateorderline
/Rune
OK, I've used NotificationCenter.Order.OrderLinesUpdating to check for the specific product type and set / force the qty to 1. Seems to work!
That's what I usually do. It's the most secure way to go. Customers can't cheat it that way.
/Rune
is working on a reply...