Odoo doesn’t natively limit how many different variants of a product can be added to the cart, but you can achieve this with a custom module or by using website sale hooks.
Here’s how you can approach it:
-
Custom Python Logic
-
Override the website_sale.cart_update_json() method.
-
Add a condition to check how many different variants of the course are already in the cart.
-
If it exceeds the limit (e.g., 1), block the addition and return a warning.
-
Alternative: Attribute Filtering
-
If you only want to show limited attribute combinations, configure those under:
Sales → Products → Attributes → Values
-
Or use the “Optional Products” feature in the Sales tab to guide user selection.
-
UI Alert (Optional)
-
Use JavaScript to show a message when a user tries to add more than one course variant.
At Wan Buffer Services, we’ve helped many eLearning businesses restrict product configurations and checkout behavior based on business rules.