Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Not Showing Zero Stock Products Automatically


varanus9

Recommended Posts

I searched all around for this, and pieced the solution together so I thought I'd share it.

 

I have a site where most things are one of a kind, and therefore when sold I wanted them to not show up in new products, category view, or product listings. You can't really set this is your admin...you can prevent it from checking out, but not from showing up unless you go in manually and change it to "out of stock"

 

You need to change five files...

 

/index.php

/products_new.php

/includes/modules/new_products.php

/includes/boxes/specials.php

/specials.php

 

In each of these files you need to find the code

 

where p.products_status = '1'

 

and change it to

 

where p.products_status = '1' and p.products_quantity > 0

 

There are a few places in index.php (sorry I don't have an exact count) and I think just one in the other files, but just do a search and replace (make sure you have a space after the zero and before the code that comes after it).

 

As always, BACK UP your stuff before doing this...

 

You can test it - make sure in admin > stock - you have check stock level *true and subtract stock *true and allow checkout *false. Then go in and put a stock quantity to 0 and it will disappear from your storefront, but not your database or your admin section. Set it back to 1 or above and it will come back again.

 

Hope this helps someone...I've gotten a lot of help from others here. This code was taken from another post, I just figured out where to add it to another couple of places to have the item disappear completely, so I take no credit. Let me know if I missed anywhere...Thanks!

 

Varanus9

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...