One thing that has always bugged me is if you set the qty of one of your product options, but on the product page you change the qty of the product to more than the amount of stock for that option, it still adds to cart, you are only notified that the qty is greater than what is in stock, when you try to check out.
Is there a way to stop someone adding a product to the cart if the qty they select is greater than the qty for the option they also select?
i.e if my product has Option A with a qty of 2, and i select option A and change product qty to 3, how can i change it so no product gets added to cart, and a warning appears stating that the qty is to high?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
It does, actually. You can either find the version build on the root index.php file or at the bottom of the admin footer-end.SXGuy wrote:OC2. I forget which sub version but I'm guessing it shouldn't matter.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I just want to disable being able to add more than what's available using stock control for options. By default you can add it to the cart but it will only tell you to change the quantity when you view basket or checkout.
I have found a mod which stops you from adding a product to the cart if you select a qty greater than what's in Stock. But I need to adapt it to include option qty also.
Prob an easy job once I take a look at the code. I just wondered if a mod had already been written. I'm guessing not as this thread would have been answered by now.
http://www.opencart.com/index.php?route ... n_id=13703
-
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS
Thank you, i would consider your mod, however i wouldnt mind trying to figure this out for myself.grgr wrote:My stock Stock Check and Max Quantity extension deals with this.
http://www.opencart.com/index.php?route ... n_id=13703
Failing that, would you consider creating a mod that just deals with option quantity for a small fee? reason being, i dont need to set a maximum or minimum quantity and so the extra code will just bloat things.
I realise i need something like
Code: Select all
if ($quantity > $option_value['quantity']) {
$json['error']['quantity'] = sprintf($this->language->get('error'), $option_value['quantity']);
}
Code: Select all
if (isset $this->request->post['quantity]
In catalog/controller/checkout/cart.php file,
find:
Code: Select all
foreach ($product_options as $product_option) {
Code: Select all
$i = 0;
foreach ($product_options as $product_option) {
if (!empty($product_option['product_option_value']) && is_array($product_option['product_option_value'])) {
$j = 0;
foreach ($product_option['product_option_value'] as $product_option_value) {
if ((int)$j == (int)$i && isset($product_option_value['quantity']) && (int)$quantity > (int)$product_option_value['quantity']) {
$json['error']['quantity'] = sprintf($this->language->get('error_quantity'), $product_option_value['quantity']);
}
++$j;
}
}
++$i;
}
find:
Code: Select all
if (json['error']['recurring']) {
Code: Select all
if (json['error']['quantity']) {
$('.breadcrumb').after('<div class="alert alert-danger">' + json['error']['quantity'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
}
add:
Code: Select all
$_['error_quantity'] = 'The product quantity cannot exceed the product option value quantity!';
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Thank you @straightlight, best answer ever.straightlight wrote:Would it be possible to provide your store URL?
It seems to only allow max qty of the option which has the least amount.
Example
Option A 20pcs
Option B 10pcs
Option C 5pcs
Will only allow a max qty of 5.
Ive even tried it like this
Code: Select all
if (!empty($product_option['product_option_value']) && is_array($product_option['product_option_value'])) {
foreach ($product_option['product_option_value'] as $product_option_value) {
if (isset($this->request->post['quantity']) && ((int)$this->request->post['quantity'] > $product_option_value['quantity'])) {
$quantity = $product_option_value['quantity'];
} else {
$quantity = $this->request->post['quantity'];
}
}
}
So im guessing it has something to do with these lines
Code: Select all
if (!empty($product_option['product_option_value']) && is_array($product_option['product_option_value'])) {
foreach ($product_option['product_option_value'] as $product_option_value) {
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: Google [Bot] and 72 guests