Page 1 of 1

Hide/disable out of stock items

Posted: Thu Feb 14, 2019 2:58 pm
by Tomi-
Hi!

I've been searching and found many threads talking about how to get this done but it just doesn't seem to work. The problem is that we need to hide or disable products from listings once they are out of stock. The nature of our shop is that we rarely have more than one of each products.

EDIT: As I have been noted, my original post had insufficient information on what I've tried. I meant to originally say that I found a lot of threads pointing somewhat in the same direction (modified the original sentence too). By following the instructions and tips from those threads, I have tried modifying the catalog/model/catalog/product.php (adding p.quantity > 0 after the p.status = '1' statement on the second entry and also for all the other entries I could find).

I appreciate all help regarding this problem!

OpenCart version: 2.3.0.2
Theme: Journal2

Kind regards,
Tomi

Re: Hide/disable out of stock items

Posted: Thu Feb 14, 2019 10:43 pm
by straightlight
I've been searching and trying out many tricks to get this done but it just doesn't seem to work.
But none of them have been posted on the topic to better described the strategies that you used in order to better described the source of the issue. Forum rules.

Re: Hide/disable out of stock items

Posted: Fri Feb 15, 2019 3:53 pm
by Tomi-
straightlight wrote:
Thu Feb 14, 2019 10:43 pm
I've been searching and trying out many tricks to get this done but it just doesn't seem to work.
But none of them have been posted on the topic to better described the strategies that you used in order to better described the source of the issue. Forum rules.
Hi Straightlight!

Thank you for your answer. I have modified my original post to better describe the situation.

Kind regards,
Tomi

Re: Hide/disable out of stock items

Posted: Wed Feb 20, 2019 6:15 am
by paid1234
Hi here is a solution to show all items that have 1 or more in the quantity field

Open Catalog/model/catalog/product.php

Find
public function getProduct($product_id) { //Usually line 7
and in the sql just below it //starts with $query = $this->db->query
Search for AND p.date_available <= NOW() //Usually towards the end of the query
right after that put a space then add the following code
AND p.quantity > 0

Now your code should look like this
AND p.date_available <= NOW() AND p.quantity > 0 AND p2s.store_id

if you get stuck let me know

Re: Hide/disable out of stock items

Posted: Wed Feb 20, 2019 3:52 pm
by Tomi-
paid1234 wrote:
Wed Feb 20, 2019 6:15 am
Hi here is a solution to show all items that have 1 or more in the quantity field

Open Catalog/model/catalog/product.php

Find
public function getProduct($product_id) { //Usually line 7
and in the sql just below it //starts with $query = $this->db->query
Search for AND p.date_available <= NOW() //Usually towards the end of the query
right after that put a space then add the following code
AND p.quantity > 0

Now your code should look like this
AND p.date_available <= NOW() AND p.quantity > 0 AND p2s.store_id

if you get stuck let me know
Hi paid1234 and thank you for your help!

I tried that modification and it didn't solve the problem. Actually there is a "p.quantity >= 1" already in place at the location you instructed me to add that modification. I also tried changing it to "p.quantity > 0" but it didn't work either.

Any idea what's wrong? Am I missing something? The products have quantity of 1 and when they're sold, the number goes to 0. Still the products remain on the listing pages but their image gets replaced by the OpenCart placeholder image and the price goes to 0.00€.

Kind regards,
Tomi

Re: Hide/disable out of stock items

Posted: Sat Feb 23, 2019 7:31 pm
by cyclops12
Hiya try This

Re: Hide/disable out of stock items

Posted: Sat May 25, 2019 8:12 pm
by paid1234
Hi sorry for the delay. if you still require help please post the code i mentioned above from your opencart version

thanks