barney12 Posted January 26, 2006 Posted January 26, 2006 Hi Please be gentle with me as I am very new to all this :D Thanks to a contrib (and a tiny bit of tweaking by me) I have added the following code (pasted below) to my product_info.php so I can show my stock status and it works a treat. But, I'm not content because as well as making the text bold I also want to chang ethe colour but if I add the <font color=""> tag I get a page error. Is there a way I can do this or am I barking up the wrong lamppost. Also whilst I write is there a way to add a stock status to the product listing pages so it shows up for each product in each row. Ideally I'd like to show 1,2,3,4,5+ like in the code below rather than the actual stock level. Thanks in advance Barney <td class="main"> <?php $prod_quantity = tep_get_products_stock($products_id); switch ($prod_quantity) { case 0: print ("<b>Product Status: Out of Stock</b>"); break; case 1: print ("<b>Product Status: We have 1 in stock</b>"); break; case 2: print ("<b>Product Status: We have 2 in stock</b>"); break; case 3: print ("<b>Product Status: We have 3 in stock</b>"); break; case 4: print ("<b>Product Status: We have 4 in stock</b>"); break; default: print ("<b>Product Status: We have 5+ in stock</b>"); } ?> </td>
tina_boots Posted January 27, 2006 Posted January 27, 2006 Hi Please be gentle with me as I am very new to all this :D Thanks to a contrib (and a tiny bit of tweaking by me) I have added the following code (pasted below) to my product_info.php so I can show my stock status and it works a treat. But, I'm not content because as well as making the text bold I also want to chang ethe colour but if I add the <font color=""> tag I get a page error. Is there a way I can do this or am I barking up the wrong lamppost. Also whilst I write is there a way to add a stock status to the product listing pages so it shows up for each product in each row. Ideally I'd like to show 1,2,3,4,5+ like in the code below rather than the actual stock level. Thanks in advance Barney <td class="main"> <?php $prod_quantity = tep_get_products_stock($products_id); switch ($prod_quantity) { case 0: print ("<b>Product Status: Out of Stock</b>"); break; case 1: print ("<b>Product Status: We have 1 in stock</b>"); break; case 2: print ("<b>Product Status: We have 2 in stock</b>"); break; case 3: print ("<b>Product Status: We have 3 in stock</b>"); break; case 4: print ("<b>Product Status: We have 4 in stock</b>"); break; default: print ("<b>Product Status: We have 5+ in stock</b>"); } ?> </td> I sounds as if you are having an issue because you are trying to display quotes inside of a string. For example: print("<div style="color:blue;">"); As far as PHP is concerned, its going to try render the line, however its going to think your string in the print function ends with style=" and then really gets confused because it expects to see a closed parm after that. There are two ways you can handle this. Numbe one would be to use the alternate single quote inside your HTML code for example: print("<div style='color:blue;'>"); Or you may use the PHP backslash delimiter: print("<div style=\"color:blue;\">"); Be well, Tina If you're not having fun you're not doing it right Teach a person to fish rather than give them a loaf of bread or however that saying goes.
barney12 Posted January 27, 2006 Author Posted January 27, 2006 Thanks Tina, thats great, all sorted. Just need to work out how to get a simular stock status into the prodcut listings page, anyone got any clues? Cheers again Barney
Recommended Posts
Archived
This topic is now archived and is closed to further replies.