Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Stock status in product_listing.php version 2.3


Aarsvaars

Recommended Posts

Hi all,

 

I was wondering if it is possible to only show a stock status image (green for in stock, red for not in stock) instead of the amount of products in stock. I have been searching the forum but I only encountered outdated topics regarding the 2.2 version.

 

Gr, Aarsvaars

Link to comment
Share on other sites

You can Modiify this:

 

If there is stock it shows the stock value - if there is no stock it shows "OUT OF STOCK" - for an image simply call an image instead of text..

 

 

// QUANTITY AVAILABLE

if($product_info['products_quantity']>0 ) {

echo TEXT_PRODUCT_STOCK_LEVEL . (($product_info['products_quantity'] > 0) ? ' (' . $product_info['products_quantity'] . ')' : '');

}

elseif ($product_info['products_quantity']<=0 ) {

echo TEXT_PRODUCT_STOCK_LEVEL . (($product_info['products_quantity'] <=0) ? ' (' . TEXT_OUT_OF_STOCK_LEVEL . ')' : '');

}

?>

Link to comment
Share on other sites

// QUANTITY AVAILABLE

if($product_info['products_quantity']>0 ) {

echo TEXT_PRODUCT_STOCK_LEVEL . (($product_info['products_quantity'] > 0) ? ' (<img src="images/YOURIMAGE-1.jpg" width="XXX" height="XXX" />)' : '');

}

elseif ($product_info['products_quantity']<=0 ) {

echo TEXT_PRODUCT_STOCK_LEVEL . (($product_info['products_quantity'] <=0) ? ' (<img src="images/YOURIMAGE-2.jpg" width="XXX" height="XXX" />)' : '');

}

?>

Link to comment
Share on other sites

Did some digging and I figured out the adjustments need to be in the file includes/modules/product_listing.php. Also I think that it has to do with the following lines:

 

<span><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></span>

Around line 164

Link to comment
Share on other sites

  • 3 weeks later...

Hi Guys

 

gfasal's solution sounds wonderful, but can I get some clarification please?

 

In OSCommerce V2.3.1

In the file catalog/product_info.php

 

There should be the code mentioned

// QUANTITY AVAILABLE
if($product_info['products_quantity']>0 ) {
echo TEXT_PRODUCT_STOCK_LEVEL . (($product_info['products_quantity'] > 0) ? ' (' . $product_info['products_quantity'] . ')' : '');
}
elseif ($product_info['products_quantity']<=0 ) {
echo TEXT_PRODUCT_STOCK_LEVEL . (($product_info['products_quantity'] <=0) ? ' (' . TEXT_OUT_OF_STOCK_LEVEL . ')' : '');
}
?>

 

& in this code we change

' (' . $product_info['products_quantity'] . ')'

 

to

' (<img src="images/YOURIMAGE-1.jpg" width="XXX" height="XXX" />)'

 

 

 

OR

 

Do I need to insert that code somewhere in catalog/product_info.php?

& if so, whereabouts exactly?

 

Thanks

Mike

Link to comment
Share on other sites

  • 1 month later...

<?php

// QUANTITY AVAILABLE

if($product_info['products_quantity']>0 ) {

echo TEXT_PRODUCT_STOCK_LEVEL . (($product_info['products_quantity'] > 0) ? ' (' . $product_info['products_quantity'] . ')' : '');

}

elseif ($product_info['products_quantity']<=0 ) {

echo TEXT_PRODUCT_STOCK_LEVEL . (($product_info['products_quantity'] <=0) ? ' (' . TEXT_OUT_OF_STOCK_LEVEL . ')' : '');

}

?>

 

 

THIS CODE IS FOR OSC 2.3.1 - WORKS FINE - SIMPLY PASTE IN PRODUCTS_INFO.PHP PAGE,

 

YOU MIGHT SAY WHERE EXACTLY... - ITS TOTALLY UP TO YOU - MAY I SUGGEST BELOW THE PRICE. CANNOT GIVE YOU A LINE NUMBER BUT MAKE A BACKUP OF YOUR PRODUCTS_INFO.PHP FILE AND THEN PASTE

THIS CODE A COUPLE OF TIMES IN THE APPROX. AREA ON THE PAGE WHERE YOU WANT IT. - AS LONG AS YOU CAN SEE IT WORKING , REOVE ANY EXTRA PASTES AND PLACE IT ACCORDINGLY.

 

 

WORKS PERFECTLY - example http://www.verdegia.com/BANO/product_info.php?products_id=419

Link to comment
Share on other sites

Works like a charm... thanks for the tip.

 

I have an extended question that you might be able to give me an answer, what if I would like to add a watermark to the image that says "Sold-out" only in case there are no more articles in stock?

 

The code to choose when to show this is the same as the one you post just in the image part, but is there a way to do this on the image without having a second image everytime?

 

Thanks for the input

Link to comment
Share on other sites

I will assume that you would like the product image (in the image box/fancy box) to show a water mark - It should be straight forward but I honestly havnt had time to look at it. give me a few days and i will come back to you with some code as its a good idea!

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...