whenever someone wants to purchase more than 99 of the same products in my shop the cart shows the "error_stock" message ("Products marked with *** are not available in the desired quantity or not in stock!"). This happens for all my products.
The quantity for my products is 9999 (or higher) and I have no options. It happens consistently for all my products.
I am using OC 3.0.2.0 my ThemeBurn (Burn Engine) theme together with some mods. However, I have no idea why this message gets triggered.
Does anyone have an idea how to trouble-shoot this?
Thanks & best,
Torge
That condition is tested in the cart class and the messages are set in the cart controller.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Even when I delete
Code: Select all
if ($option_value_query->row['subtract'] && (!$option_value_query->row['quantity'] || ($option_value_query->row['quantity'] < $cart['quantity']))) {
$stock = false;
} }
Also I noticed that in the DB product quantity is an int(4) field. Higher values do save and show in admin but could this lead to trouble?
This problem is driving me insane!
Cheers,
Torge
Code: Select all
if ($option_value_query->row['subtract'] && (!$option_value_query->row['quantity'] || ($option_value_query->row['quantity'] < $cart['quantity']))) {
$stock = false;
}
Code: Select all
// Stock
if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity'])) {
$stock = false;
}
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
It sounds like you just don't want to use stock control? So you should be able to turn that off in the admin?
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Darn, I posted the wrong code, sorry. In fact even when I delete the lines you posted I still get the same error message....

I already search all my code (incl. extensions) for another "$stock = false" but there is no such line anywhere else. Any other idea on how to bugfix this?
re: paulfeakins
I do want to use this for most products but not all. For the product in question I set "subtract from stock" to no. Still getting the error.
Code: Select all
if (!$this->cart->hasStock() && (!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning'))) {
$data['error_warning'] = $this->language->get('error_stock');
} elseif (isset($this->session->data['error'])) {
$data['error_warning'] = $this->session->data['error'];
Code: Select all
public function hasStock() {
foreach ($this->getProducts() as $product) {
if (!$product['stock']) {
return false;
}
}
return true;
}
so the individual cart items have a value stock which may be false and the function hasStock will return false if any of the cart items has stock set to false.
you could print those values in the error_log to see if any of them gets set to false.
Are you sure you are editing the right source?
You do not have additional sources in modifications?
Test it by adding error_log('testing'); somewhere to make sure.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
yes, I edited the correct code and still get the same message. Funny thing is: Everything works as expected. Meaning that when a product has an availability of 35 the checkout works with 35 and throws an error beginning at 36. This works correct for all products. Only when I put a product to 100 and above I always get the error message no matter what the availability of the specific product is.
Thanks & best,
Torge
Code: Select all
$stock = false;
If you still do, you are editing the wrong source.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
I finally come around to work on this again. I am still having this problem. However, I found that @letxobnav was right fun that there was a modification that lead to my changes not showing up. In fact, when I change the hasStock function in the cart library to this
Code: Select all
public function hasStock() {
return true;
}
Code: Select all
if (!$this->cart->hasStock() && (!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning'))) {
I someone wants to take a look on my dev I'd really appreciate it. I'd gladly pay for it, too. Please answer here if interested.
Thanks & Best,
Torge
Attachments
Bildschirmfoto 2020-10-20 um 15.24.10.png (247.55 KiB) Viewed 841 times
You may see something like...
Code: Select all
{% if not product.stock %} <span class="text-danger">***</span> {% endif %}
Code: Select all
'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')),
Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!
thanks a lot for your reply. You are right in that when I edit the line accordingly the warnings in the product table disappear. However, this is the same outcome I could achieve by changing the setting in admin (that availability is just not checked anymore). The underlying problem is that the availability check does not work in my case. The hasStock() function somehow always returns false if the cart amount for any given product exceeds 100. Any idea on how to bugfix this?
Thanks & best,
Torge
Users browsing this forum: No registered users and 68 guests