Posted on 19/02/2018 15:33:24
Hi Jens,
That is a tough one. You could use some Razor to determine if you alredy exceeded the maximim quantity and either decrease or remove an entire ordeline, but to do it right, it should be done through an order (or orderline) notification.
We would typically do this in projects with integration and let the ERP handle the limitations, so there's little business logic on our end.
If you absolutely need to do this in templates (although not being the best way to do it, and you might run into some edge case scenarios you might not control), you could develop all of the logic to check whether or not the cart has exceeded the max number of products, and if so, you could instantiate the order using the api https://doc.dynamicweb.com/api/html/3a0dba47-d919-e94f-3ab6-19202bf9b0c9.htm, update and save your cart. Once that is done.
To render the updated cart you might use the cart or reload the page and use the tags.
Hope that makes sense.
Nuno Aguiar