Guest Posted December 2, 2006 Posted December 2, 2006 Hi all, Trying to get a stock status indicator working properly on our site at the moment which displays within the product info screen.. I was sent the following code by a friend earlier on this year who also has an OSC site and has this working, I pasted it in exactly the same place he has in product_info.php and it will only show the status as "Out of stock" regardless of how many we actually have in the qty box under admin. <?php $prod_quantity = tep_get_products_stock($products_id); switch ($prod_quantity) { case -5: print '<img src="images/stock_soldout.gif" border="0">'; break; case -4: print '<img src="images/stock_soldout.gif" border="0">'; break; case -3: print '<img src="images/stock_soldout.gif" border="0">'; break; case -2: print '<img src="images/stock_soldout.gif" border="0">'; break; case -1: print '<img src="images/stock_soldout.gif" border="0">'; break; case 0: print '<img src="images/stock_soldout.gif" border="0">'; break; case 1: print '<img src="images/stock_limitedstock.gif" border="0">'; break; case 2: print '<img src="images/stock_instock.gif" border="0">'; break; case 3: print '<img src="images/stock_instock.gif" border="0">'; break; case 4: print '<img src="images/stock_instock.gif" border="0">'; break; default: print '<img src="images/stock_instock.gif" border="0">'; } ?> First of all i don't know if this is an actual added contribution for OSC on this site, if it is then can someone please forward me to the support thread ? Any help will be apreciated i'm pulling my hair out here! :'(
Daemonj Posted December 3, 2006 Posted December 3, 2006 Wow, that is some seriously inefficient code. :o Why not try something like: $prod_quantity = tep_get_products_stock($products_id); if ($prod_quantity < 1) { // out of stock echo tep_image(DIR_WS_IMAGES . 'stock_soldout.gif'); } else { // in stock echo tep_image(DIR_WS_IMAGES . 'stock_instock.gif'); } "Great spirits have always found violent opposition from mediocre minds. The latter cannot understand it when a man does not thoughtlessly submit to hereditary prejudices but honestly and courageously uses his intelligence." - A. Einstein
Guest Posted December 3, 2006 Posted December 3, 2006 Wow, that is some seriously inefficient code. :o Why not try something like: $prod_quantity = tep_get_products_stock($products_id); if ($prod_quantity < 1) { // out of stock echo tep_image(DIR_WS_IMAGES . 'stock_soldout.gif'); } else { // in stock echo tep_image(DIR_WS_IMAGES . 'stock_instock.gif'); } Hi Daemonj, Thanks for the reply.. Just tried that code you said quickyl and it's basically doing the same as the one i posted up by always showing stuff as out of stock regardless of what the qty is set in the admin side.. Its not too much of a problem now anyway, i've found an actual contribution that im in the middle of moddifying now so it works better with our store, this one also does show the stock correctly :) For anyone who wants to try this its: Quantity availability image and text Unlimited (sorry i havent got the link to this) I'll give you a shout if i can't get this one working, but thanks for your help!
Guest Posted December 3, 2006 Posted December 3, 2006 Hi Daemonj, Thanks for the reply.. Just tried that code you said quickyl and it's basically doing the same as the one i posted up by always showing stuff as out of stock regardless of what the qty is set in the admin side.. Its not too much of a problem now anyway, i've found an actual contribution that im in the middle of moddifying now so it works better with our store, this one also does show the stock correctly :) For anyone who wants to try this its: Quantity availability image and text Unlimited (sorry i havent got the link to this) I'll give you a shout if i can't get this one working, but thanks for your help! can you please show me the contribution or what you have done when you are finished, I have been looking for something exactly like this.!!! Thanks
Guest Posted December 4, 2006 Posted December 4, 2006 can you please show me the contribution or what you have done when you are finished, I have been looking for something exactly like this.!!! Thanks This is what i'm using.. you can modify it to your own needs: http://www.oscommerce.com/community/contributions,2507
Recommended Posts
Archived
This topic is now archived and is closed to further replies.