Post by mwshark » Fri Dec 09, 2011 12:00 am

Hi all,

I have been searching high and low for a solution to this.

Problem:

I would like to display a warning to the users of the website if they enter a quantity which exceeds the available stock. This is similar to the warning shown when you are in the checkout, however I do not want them to get as far as adding to the cart if they are trying to order too many items.

Solution:

I am looking for something which will display 1) a error message and 2) not add the item to the shopping cart if Product total is greater than the available quantity.

Any suggestions would be appreciated, apologies if it has been asked before - I did do a search.

Cheers

V1.5.2 (With Vqmod installed)

[Edit: I do have this Vqmod installed - http://www.opencart.com/index.php?route ... order=DESC
which works perfectly for fixed maximum quantity limits, however if there is a way to change this so that it also reads the quantity figure from the product table that would be good too]

Newbie

Posts

Joined
Thu Dec 08, 2011 11:56 pm

Post by grgr » Fri Dec 09, 2011 1:18 am

To get you going...

Edit ../catalog/controller/checkout/cart.php.

Find

Code: Select all

				if ($product_info['minimum'] > ($product_total + $quantity)) {
					$json['error']['warning'] = sprintf($this->language->get('error_minimum'), $product_info['name'], $product_info['minimum']);
				}
Directly below ADD:

Code: Select all

				if ($product_info['quantity'] < ($product_total + $quantity)) {
					$json['error']['warning'] = sprintf($this->language->get('error_minimum'), $product_info['name'], $product_info['minimum']);
				}
You'll need to change the warning message though.

Seems to work.

-
Image Image Image Image
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS


User avatar
Active Member

Posts

Joined
Mon Mar 28, 2011 4:08 pm
Location - UK

Post by mwshark » Fri Dec 09, 2011 1:41 am

Kudos to you.

Thank you very much. I added a new line in the language file and it works just as intended.

Appreciated

Newbie

Posts

Joined
Thu Dec 08, 2011 11:56 pm

Post by Guppi » Mon Mar 12, 2012 6:56 pm

this code is not working for me because I had added the redirect functionality when the user clicks on add to cart. So how to disable redirection to cart page if quantity < total ?

Newbie

Posts

Joined
Mon Mar 12, 2012 6:55 pm

Post by MarkIce » Wed May 11, 2016 6:37 pm

hi,

can anyone please update to be used on 1.5.6.4 or anyone know a better way of doing it, very greatfull

cheers all..

New member

Posts

Joined
Sat Mar 01, 2014 5:58 am

Post by karimzi_academy » Thu Jun 03, 2021 12:45 am

try this free extension https://karimzi.blogspot.com/2021/06/op ... ntity.html

I hope you will get solution.


Posts

Joined
Thu Jun 03, 2021 12:41 am
Who is online

Users browsing this forum: No registered users and 121 guests