Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Out-Of-Stock Products Automatically Not Displayed


blueedge

Recommended Posts

When a customer buys the last unit of a given item, the store automatically sets that particular product page not to be displayed. When we run out of an item, we receive more inventory fairly quickly. As a result, I would like to continue to display the product even if it has zero inventory. How/where can I change that setting so that products with zero inventory remain displayed by default?

 

I know I can go to the admin and manually set a product to be displayed. However, I would like to change the default to display the product with zero inventory and have to manually change it to "not to be displayed" in the admin, if desired.

 

Thanks.

Link to comment
Share on other sites

Normally

 

Admin >> Configuration >> Stock shows a page where this is normally controlled.

 

Do you have any contributions installed to control how out of stock lines are displayed?

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites

Thanks for the reply, Geoffrey.

 

I have looked in the Admin>Configuration section. While I have found controls such as "Prevent Adding Out of Stock to Cart" and "Mark product out of stock," I have not found what controls the product from automatically not being displayed when inventory reaches zero. ("Mark product out of stock" merely controls what symbol "***" is used to display items in the cart that have less quantity than ordered.)

 

I also have a number of contributions. However, I'm not certain what they are. I do have a contribution that allows inventory by attribute. So, I also have controls such as "Show Out of Stock Attributes" (which keep an out-of-stock attribute in the dropdown list on the product page but marks it as "Out Of Stock").

 

Am I just overlooking where the control is to automatically remove a product from display when inventory reaches zero? Is there some other place I should look?

 

Thanks.

Link to comment
Share on other sites

You could add a where clause to the sql e.g.

 

where stock level > 0

 

see w3.schools.com for more info on sql.

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites

  • 7 months later...

I'm amazed that no one has previously posted a solution to this very basic issue: Blocking the display of products with zero inventory.

I'm amazed that this isn't the default state for osCommerce.

I'm amazed there is no switch to turn the display of these products on or off.

But it is what it is so I hope this helps.

 

I found a query in file

products_new.php

on

line 54

If you add

p.products_quantity > 0 and

To

where p.products_status = '1'

Resulting in

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

 

This will block the display of products with zero inventory in the default page of index.php and the new products page products_new.php.

 

For other pages such as those which result from the search function, it appears to involve the code that defines $listing_sql in the file index.php.

I have not yet found the correct code to block products with zero inventory for these pages but, I assume, it will require a similar solution.

If I solve this issue before anyone else does, I'll edit this post with the information.

Link to comment
Share on other sites

  • 4 months later...

Here's the solution:

 

in file checkout_process.php, find the following lines and comment them out.

 

Find:

	  if ($stock_left < 1) {
	tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
  }

 

Comment out, as such:

 //	 if ($stock_left < 1) {
//	   tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
//	 }

Link to comment
Share on other sites

You can also make a check in your product_info.php to tell customers that the product is on backorder. Just place this in your product_info page wherever you want it.

 

<?
  if ($product_info['products_quantity'] < 1)
  {
	  echo "This product is currently on backorder";
  } else {
	  echo "Quantity Available: " . $product_info['products_quantity'] . " in stock";
  }
?>

Link to comment
Share on other sites

...and to reset all of your products back to "active" status from the command-line... This will set ALL PRODUCTS ACTIVE so don't do it unless that's what you want!

 

mysql -uroot -p your_osc_databasename -e "update products set products_status = '1' where 1"

 

Enter your mysql root password at the prompt -

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...