Developer forum

Currently discussing: Plans to implement a Consent module for GDPR compliance.

Join the discussion!

Forum » Templates » Max number of products from a specific product category

Max number of products from a specific product category

Jens Mouritzen
Jens Mouritzen
Reply

I need a setting, where i can set a max number of products from a specific product category, that buyers can put in the cart pr. order.

An example: a festival where visitors buy a workshop, and they can only put one workshop in the cart pr. order.

Does such a feature exist? Should it be made in the templates?

Thanks

Replies

 
Jens Mouritzen
Jens Mouritzen
Reply

Anyone have an suggestion ?

 
Jens Mouritzen
Jens Mouritzen
Reply

Anyone have an idea?

 
Nuno Aguiar
Nuno Aguiar
Reply

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

 

You must be logged in to post in the forum