I need to let the 0 stock products or the out of stock products to be hidden,
I tried what the other threads said, but with no luck. extensions did not help as well.
using OC 3, with the Devman opt. comb. extension
Forum: viewtopic.php?p=827756#p827756 .
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Thank you for your reply, I tried what that thread said, it disabled the products but I still can see them on the website (when I click on it, it says product is unavailbe but its still there)straightlight wrote: ↑Thu Apr 20, 2023 7:58 amMarketplace: https://www.opencart.com/index.php?rout ... of%20stock .
Forum: viewtopic.php?p=827756#p827756 .
As for the extensions, do you have any recommendations? have you tried any of them?
Thank you.
Zero quantity (out of stock) and disable are not the same things.
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
Thank you for your reply.
The thing I did from that thread, kept the product in the front end, but when I click on it it says product not found,
I need to hide it from the front end in the first place. (I dont't want people to see a product, click on it and it shows an empty page)
If, as your title post suggests you want to hide products that are with a quantity of zero without disabling the product, as I said, that is different.
An example of an easy way to do that :
config.php:
add:
Code: Select all
// switch to hide or show products with zero stock
define('HIDE_ZERO_STOCK', true);
before:
Code: Select all
if (!empty($data['filter_manufacturer_id'])) {
Code: Select all
if (HIDE_ZERO_STOCK) {
$sql .= " AND p.quantity > 0 ";
}
for a module like latest products you would have to split the query in function getLatestProducts(...)
from:
Code: Select all
$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);
Code: Select all
$sql = "SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1'";
if (HIDE_ZERO_STOCK) $sql .= " AND p.quantity > 0 ";
$sql .= " AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit;
$query = $this->db->query($sql);
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
Thank you for your reply,by mona wrote: ↑Thu Apr 20, 2023 9:22 pmYou do not use an extension if you just intend to disable a product. If it is disabled in admin, then it does not appear by default in the front end. If you have an extension that effects that behaviour you just need to disable the extension. Products which are disabled have no link to click, if there is, that means that it is in extension that is effecting the behaviour. or you have caching which is old data still showing (the link) but the product is not actually there. For that you will have to refresh all cache.
If, as your title post suggests you want to hide products that are with a quantity of zero without disabling the product, as I said, that is different.
An example of an easy way to do that :
config.php:
add:catalog/model/catalog/product.php in functions getProducts(...) and getTotalProducts(...)Code: Select all
// switch to hide or show products with zero stock define('HIDE_ZERO_STOCK', true);
before:add:Code: Select all
if (!empty($data['filter_manufacturer_id'])) {
Code: Select all
if (HIDE_ZERO_STOCK) { $sql .= " AND p.quantity > 0 "; }
for a module like latest products you would have to split the query in function getLatestProducts(...)
from:to:Code: Select all
$query = $this->db->query("SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit);
Same principle for bestsellers and popular products, just add the p.quantity > 0 condition if set by the switch.Code: Select all
$sql = "SELECT p.product_id FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE p.status = '1'"; if (HIDE_ZERO_STOCK) $sql .= " AND p.quantity > 0 "; $sql .= " AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' ORDER BY p.date_added DESC LIMIT " . (int)$limit; $query = $this->db->query($sql);
I tried your solution on a vanila OC I have on a localhost, it worked fine,
but when I tried it on my OC site it didnt work, I cleared chache and made sure no other extensions were enabled. I can still see those out of stock products.
I also see them in my search results page and in catagory page, I dont know if that woudl require other steps.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Demo PprMkr Soldcorners for OC 4.0.2.1

When 'Hide product' is enabled, product is invisible for visitor.
That looks really great,pprmkr wrote: ↑Wed Apr 26, 2023 2:58 pmOut of stock products with notice 'Out of stock' and add to cart button disabled ? The notice is whatever 'Out Of Stock Status' is set.
Demo PprMkr Soldcorners for OC 4.0.2.1
When 'Hide product' is enabled, product is invisible for visitor.
where can I find that?
I try to understand and use events to replace the ocMods created for OC 3.*
SoldCorners for OC 3.0.2.* and 3.0.3.* has no 'Hide' option. It is 1 ocMod.xml file with stylesheet and image.
Demo for 3.0.2.0 version
Great support as well.
https://www.opencart.com/index.php?rout ... n_id=39066
Users browsing this forum: No registered users and 103 guests