Post by Tomi- » Thu Feb 14, 2019 2:58 pm

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
Last edited by Tomi- on Fri Feb 15, 2019 3:56 pm, edited 3 times in total.

Newbie

Posts

Joined
Tue Dec 04, 2018 6:38 pm

Post by straightlight » 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.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Tomi- » Fri Feb 15, 2019 3:53 pm

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

Newbie

Posts

Joined
Tue Dec 04, 2018 6:38 pm

Post by paid1234 » 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

User avatar
Newbie

Posts

Joined
Thu Aug 01, 2013 8:37 am
Location - United Kingdom

Post by Tomi- » Wed Feb 20, 2019 3:52 pm

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

Newbie

Posts

Joined
Tue Dec 04, 2018 6:38 pm

Post by cyclops12 » Sat Feb 23, 2019 7:31 pm

Hiya try This

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by paid1234 » Sat May 25, 2019 8:12 pm

Hi sorry for the delay. if you still require help please post the code i mentioned above from your opencart version

thanks

User avatar
Newbie

Posts

Joined
Thu Aug 01, 2013 8:37 am
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 352 guests