0

Is there any easy way to show a warning in the product page and prevent adding product to cart instead of showing the message in cart page, when the quantity increments entered in quantity input field are incorrect?

Thanks

1 Answer 1

0

You can create a block that would be called before_body_end based on events responsible for product listing and product view.

In that block you could generate data for template file in which you'd loop over the data and generate JavaScript array of minimum/maximum/increment quantities.

Then create a JS function that will prevent submission of the product view form/product list button unless the min/max/inc quantities are correct in the quantity input. Input quantities would need to be specified with a product-id so you can find associated value in JS array easily.

If you don't understand something or have a problem with specific fragment of code, edit your question and I'll update my answer accordingly.

1
  • thank you very much, I will update my question soon with some of the code I am trying to write! Commented Sep 8, 2016 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.