Hello Opencart Masters!
Im just wondering if it is possible to hide out of stock products in the Latest Module?
Im not a programmer or web developer but is trying to study the work-around of Opencart. I do have an online store which i set-up without the help of any programmer. I just read articles on how to install and setup Opencart. I also use the free modules/extensions in the Extensions page and is happy with what my store looks like.
The only thing that is bothering me is that every time I mark a product as out of stock, it still appears in the Latest Products in the Homepage. Is there a way to automatically hide it when stock is set to zero?
Hope you can help an ordinary person like me. Thank you and More Power!
ogie_v
Im just wondering if it is possible to hide out of stock products in the Latest Module?
Im not a programmer or web developer but is trying to study the work-around of Opencart. I do have an online store which i set-up without the help of any programmer. I just read articles on how to install and setup Opencart. I also use the free modules/extensions in the Extensions page and is happy with what my store looks like.
The only thing that is bothering me is that every time I mark a product as out of stock, it still appears in the Latest Products in the Homepage. Is there a way to automatically hide it when stock is set to zero?
Hope you can help an ordinary person like me. Thank you and More Power!
ogie_v
I forgot to say
If this question was answered before, I hope someone can give me the link to the thread. Thanks Opencart.
Im using v1.5.1.3 Opencart using Yooblue Free theme.
By the way, my online store is http://www.tindahanmo.com
Cheers!!
If this question was answered before, I hope someone can give me the link to the thread. Thanks Opencart.
Im using v1.5.1.3 Opencart using Yooblue Free theme.
By the way, my online store is http://www.tindahanmo.com
Cheers!!
1. EDIT: catalog/controller/module/latest.php
2. FIND:
3. BEFORE, ADD:
4. DELETE all files from SYSTEM/CACHE folder via FTP
2. FIND:
Code: Select all
if ($result['image']) {
Code: Select all
if (!$result['quantity']) { continue; }
Thanks for the code Qphoria. It works just as we wanted but just wondering if we can make it replace those hidden products with the next latest ones in the list, as it just hides them and doesn't show the next latest products but instead shows blank spaces.
Example: On my site I have a 16 item latest product module and 4 of them are sold out (most of my sales are from homepage for the latest items) , when they go out of stock the code hides them but instead of looking for the next latest products to add to the grid it just leaves the grid with 12 products now.
This would be very much appreciated, most of my abandoned orders are because the customers cart contains out of stock products so they just abandon ship on the rest. Thanks much!
I can pay $10 to whoever can do this for me, Please PM me ASAP. Thank you!
Example: On my site I have a 16 item latest product module and 4 of them are sold out (most of my sales are from homepage for the latest items) , when they go out of stock the code hides them but instead of looking for the next latest products to add to the grid it just leaves the grid with 12 products now.
This would be very much appreciated, most of my abandoned orders are because the customers cart contains out of stock products so they just abandon ship on the rest. Thanks much!
I can pay $10 to whoever can do this for me, Please PM me ASAP. Thank you!
Edit catalog/model/catalog/product.php
On line 230:
Add: AND p.quantity > 0
Or replace by attached model.
Easy earned
On line 230:
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
$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.quantity > 0 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);
Easy earned

Hey PP, I added the code as you said and didn't see any changes. I even uploaded the file and replaced it with the one I had.
On my home page there's still blank spaces for Latest Items..
look at my home page www . canamos . com
There is suppose to be 16 items in the Latest module but the last ones are out of stock so it doesn't retrieve the next in line and it just leaves blank spaces.
Also, could it be because of my theme?
I'm using 1.5.x version of opencart
On my home page there's still blank spaces for Latest Items..
look at my home page www . canamos . com
There is suppose to be 16 items in the Latest module but the last ones are out of stock so it doesn't retrieve the next in line and it just leaves blank spaces.
Also, could it be because of my theme?
I'm using 1.5.x version of opencart
NVM, GOT IT WORKING THANK YOU SOO MUCH!!
For those who are still trying to figure this out:
you have to add p.quantity > '0' to this code as well
If you can't find it what I did was search for p.status and then click find , click find again and after the second p.status that's where you add it ! Thanks to pp for pointing us in the right direct he takes the cake lol 
For those who are still trying to figure this out:
you have to add p.quantity > '0' to this code as well
Code: Select all
public function getProducts($data = array()) {
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getCustomerGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$cache = md5(http_build_query($data));
$product_data = $this->cache->get('product.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . (int)$customer_group_id . '.' . $cache);
if (!$product_data) {
$sql = "SELECT p.product_id, (SELECT AVG(rating) AS total FROM " . DB_PREFIX . "review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM " . DB_PREFIX . "product p LEFT JOIN " . DB_PREFIX . "product_description pd ON (p.product_id = pd.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id)";
if (!empty($data['filter_tag'])) {
$sql .= " LEFT JOIN " . DB_PREFIX . "product_tag pt ON (p.product_id = pt.product_id)";
}
if (!empty($data['filter_category_id'])) {
$sql .= " LEFT JOIN " . DB_PREFIX . "product_to_category p2c ON (p.product_id = p2c.product_id)";
}
$sql .= " WHERE pd.language_id = '" . (int)$this->config->get('config_language_id') . "' AND p.status = '1' AND p.quantity > '0' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "'";

I know this is an old thread, but I found this one in the search and it's exactly what I was looking for. It works like a charm. I did the deleting files as in step 4, but now the search function won't work anymore.
This is the error:
Notice: Error: Table 'thestamp_db.product_tag' doesn't exist
Error No: 1146
SELECT COUNT(DISTINCT p.product_id) AS total FROM product p LEFT JOIN product_description pd ON (p.product_id = pd.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN product_tag pt ON (p.product_id = pt.product_id) WHERE pd.language_id = '1' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '0' AND ( LCASE(pd.name) LIKE '%dancing%' OR LCASE(pt.tag) LIKE '%dancing%' AND pt.language_id = '1') in /home/thestamp/public_html/system/database/mysql.php on line 49
Is there a work around to get the search option back to work?
thanks in advance!
This is the error:
Notice: Error: Table 'thestamp_db.product_tag' doesn't exist
Error No: 1146
SELECT COUNT(DISTINCT p.product_id) AS total FROM product p LEFT JOIN product_description pd ON (p.product_id = pd.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN product_tag pt ON (p.product_id = pt.product_id) WHERE pd.language_id = '1' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '0' AND ( LCASE(pd.name) LIKE '%dancing%' OR LCASE(pt.tag) LIKE '%dancing%' AND pt.language_id = '1') in /home/thestamp/public_html/system/database/mysql.php on line 49
Is there a work around to get the search option back to work?
thanks in advance!
Who is online
Users browsing this forum: No registered users and 16 guests