Prevent Add to Cart If Quantity Is Greater Than In Stock

Prevent Add to Cart If Quantity Is Greater Than In Stock

In the default install of OpenCart, customers can successfully add any quantity to their cart, regardless of the quantity that is actually in stock. They are able to see which items have a lower stock quantity than they requested in the shopping cart, however, this will only frustrate the customer. After completing their shopping, and reviewing their cart, they are now finding out that they cannot order a certain amount of a product they want. They can try to adjust the quantity in the cart, but now they have no idea how many they can actually purchase, so they have to go back to the product page to find out how many are available, then start the process all over again.

This extension compares the quantity available in stock to the quantity the customer is requesting. If the requested quantity is higher than what's in stock, an error message will display stating that they have requested more than the quantity in stock and the products will not be added to the cart until they adjust their quantity. This extension also prevents the customer from trying to add multiple quantities repeatedly in an attempt to trick the module. For example: if product "x" only has 9 available, the program will not allow the customer to add 5 + 5. They can add 5 + 4, but cannot exceed the total available.

In addition, this extension also grays out and disables the "Add to Cart" button on the product page, category page, search page, bestsellers, featured, latest, manufacturers, compare, wishlist and specials when the stock is equal to 0. The "Out of Stock" buttons will redirect your customer to the product page.

-NOTE: Product options are not currently separated. If there is enough interest in this, I may add it to a future release.

Tested on default template. May work on other templates. Contact me for simple modifications to custom templates if needed.


-v2.0.0 - OpenCart 2.0 -
-v1.2.0 - OpenCart 1.5.6 -
- works with default template
- vqmod required

for support, please contact


  • Developed by OpenCart Community
  • Documentation Included


Compatibility,,, 1.5.4,,, 1.5.6,,,,

Last Update
28 Jan 2015

6 Nov 2014
46 Sales
Member since: 6 Jun 2012

View all extensions Get Support