Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Errors in Product Stock Code - Help Needed!


Guest

Recommended Posts

Posted

Hi Guys,

 

This is the current contribution for 'Product Stock Message' which I am trying to edit.

 

The initial code is as such:

 

<tr>

<td class="main">

 <?php

 $prod_quantity = tep_get_products_stock($products_id);

 switch ($prod_quantity) {

     case 0:

     print "Out of Stock";

     break;

     case 1:

     print "We have 1 in stock";

     break;

     case 2:

     print "We have 2 in stock";

     break;

     case 3:

     print "We have 3 in stock";

     break;

     case 4:

     print "We have 4 in stock";

     break;

     default:

     print "We have 5+ in stock";

 }

 ?>

</td>

</tr>

 

The code which I am trying to modify it to is as follows to show a graphic instead of text

 

Here is my edited code:

 

 

<?php

 $prod_quantity = tep_get_products_stock($products_id);

 switch ($prod_quantity) {

     case 0:

     print "<img src="images/product_info_sold_out.gif" border="0">";

     break;

     case 1:

     print "<img src="images/product_info_low_stock.gif" border="0">";

     break;

     case 2:

     print "<img src="images/product_info_low_stock.gif" border="0">";

     break;

case 3:

     print "<img src="images/product_info_in_stock.gif" border="0">";

     break;

     case 4:

     print "<img src="images/product_info_in_stock.gif" border="0">";

     break;

     default:

     print "<img src="images/product_info_in_stock.gif" border="0">";

 }

 ?>

 

You can see the basic changes to the edit. Of course it's not working.

 

Any ideas how I can change the code from display text to images and getting it to work???

 

The error I recieve is:

 

Parse error: parse error, unexpected T_STRING in .../mygeekshop.com/httpdocs/v2/catalog/product_info.php on line 120

 

Any ideas? Hopefully it's an easy fix for someone. Once done I will add it to the contribution list.

 

Cheers,

James

Posted

Linda

 

So should it be the following?:

 

print "<img src=images/product_info_sold_out.gif border=0>";

 

Am I right?

 

Thanks in advance

James

Posted

Yippie it works!!!

 

 

 

<?php 

 $prod_quantity = tep_get_products_stock($products_id); 

 switch ($prod_quantity) { 

     case 0: 

     print '<img src="images/product_info_sold_out.gif" border="0">'; 

     break; 

     case 1: 

     print '<img src="images/product_info_low_stock.gif" border="0">; 

     break; 

     case 2: 

     print '<img src="images/product_info_low_stock.gif" border="0">'; 

     break; 

case 3: 

     print '<img src="images/product_info_in_stock.gif" border="0">'; 

     break; 

     case 4: 

     print '<img src="images/product_info_in_stock.gif" border="0">'; 

     break; 

     default: 

     print '<img src="images/product_info_in_stock.gif" border="0">'; 

 } 

 ?>

 

Will be adding this to the contribution area shortly with a couple of nice graphics :-)

 

*proud of creating something*

Archived

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

×
×
  • Create New...