I am using Woocommerce and need the following:
As product is being sold to another country and that country's customs only allow a total quantity of 6, so I need to prevent customers from order more than 6 items (products).
6 is the total of items or products. Customer can order 1 product in quantity of 6 or 2 products with quantity of 3 each. Customs will only allow a total number of items to be 6.
If there are more then 6 items in the cart, a warning should appear and prevent customer from proceeding to check out.
Is this possible to limit cart items to 6 and to display a message when this limit is exceeded?
You can add additional validation parameters when validating the product being added to cart.
woocommerce_add_to_cart_validation
expects atrue
orfalse
value to be returned depending on whether the product is OK to be added to the cart: