Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Can anyone help with a select statement?


mugitty

Recommended Posts

I have my product_info set so that a given quantity of a product will yield a statement relating to shipping time or means through a switch

<tr>

<td class="main"><br>Shipping weight:

<?php echo tep_get_products_weight($products_id); ?> lbs.

<td align="right" class="main"><b>Quantity:</b> <input type="text" name="cart_quantity" value="1" size="3"> <input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'align="absmiddle"'); ?></td>

</tr>

<tr>

<td colspan="2" class="main">

<?php

 $prod_quantity = tep_get_products_stock($products_id);

 switch ($prod_quantity) {

     case 0:

     print "<b><font size=4 color=red>CC</font> - This item ships via common carrier and should be ordered separately from other products.</b>

            <br>Select "<font color=red><b>CC</b></font>" for shipping method at checkout, as shipping costs for other methods will not be accurate.

            We will contact you with a freight quote prior to fulfilling your order. You may also <a href="mailto:[email protected]?subject=Freight Quote Request - ". $product_info_values['products_model'] .""><font color=red>email</font></a> us for a quote. Please include destination City, State and ZIP";

     break;

     case 1:

     print "<b><font size=4 color=red>FREE SHIPPING</font> (continental U.S. only)<br>Order separately from non-free shipping products</b>

            <br>Select "<font color=red><b>FS</b></font>" for shipping method at checkout to destinations within the lower 48 U.S. states only.

            <br>For all other destinations, normal U.S.P.S. shipping charges apply.";

     break;

     case 2:

     print "<b>Special Order/Limited Quantity - Please <a href="mailto:[email protected]?subject=Product Availability Inquiry - ". $product_info_values['products_model'] .""><font color=red>email</font></a> us for current availability</b>";

     break;

     case 3:

     print "<b>Special Order - Normally ships within 10-15 business days</b><br>If delayed, we will email you for instructions";

     break;

     case 4:

     print "<b>This item normally ships within 3-5 business days</b><br>If delayed, we will email you for instructions";

     break;

     default:

     print "<b>This item normally ships within 48 hours</b><br>If delayed, we will email you for instructions";

 }

 ?>

</td>

</tr>

The quantity selection box and add to cart button always show. I would like to add another case (case 6) which would indicate that the product was only available for local purchase and not available to be shipped outside of the local area. In this case, I would like to replace the selection box and add to cart button with some text, but I can't quite figure out how to write the "if/else" to produce this.

 

Any pointers would be greatly appreciated!

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Link to comment
Share on other sites

Well, I'm going to guess here, and keep in mind that this won't be tested, but I think it should work. If you take the code that makes up the quantity box, and the add to cart button and stick it in every case statement except the one you don't want it to appear in, then it will show up in every case except the one you left it out of. Follow me? So for case 1 through 5, cut

<tr>

<td class="main"><br>Shipping weight:

<?php echo tep_get_products_weight($products_id); ?> lbs.

<td align="right" class="main"><b>Quantity:</b> <input type="text" name="cart_quantity" value="1" size="3"> <input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'align="absmiddle"'); ?></td>

</tr>

and stick it in the beginning of the first 5 case statements. For example case 0 would look like this:

case 0:

<tr>

<td class="main"><br>Shipping weight:

<?php echo tep_get_products_weight($products_id); ?> lbs.

<td align="right" class="main"><b>Quantity:</b> <input type="text" name="cart_quantity" value="1" size="3"> <input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'align="absmiddle"'); ?></td>

</tr> 

print "<b><font size=4 color=red>CC</font> - This item ships via common carrier and should be ordered separately from other products.</b>

            <br>Select "<font color=red><b>CC</b></font>" for shipping method at checkout, as shipping costs for other methods will not be accurate.

            We will contact you with a freight quote prior to fulfilling your order. You may also <a href="mailto:[email protected]?subject=Freight Quote Request - ". $product_info_values['products_model'] .""><font color=red>email</font></a> us for a quote. Please include destination City, State and ZIP"; 

break;

 

So for any case that you don't have that code, the quantity box and button won't show up. I think it might work. If not, it's a start. Good luck.

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

James;

 

Thank you for your reply. I will certainly give your solution a try if I don't get this other way to work. Shouldn't I be able to write something like:

 

if case =6 show the call us for details text

else show the quantity box and add to cart button

 

I had tried several times to do it this way, but strangely was receiving errors which identified the last line of the product_info.php file which hadn't been altered. To date I haven't been able to get past that stumbling block.

... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Link to comment
Share on other sites

Well, when you say "if case=6", you are pretty much defining your switch statement. The first line of your switch statement:

 

switch ($prod_quantity) {

 

which essential says "if case = (whatever the product quantity is) then do whatever is indicated in the case statement corresponding to whatever $prod_quantity is eqal to. So you already have if case=6. If case doesn't equal six then it will do one of the other case statements, if it doesn't equal any of those, it will do the default statement. You can replace the switch with a bunch of if else statements if that is what you're after. What I wrote would say for every case, show the quantity box and add to cart, but if case = 6, then just show the text. You shouldn't need any more if else statements with the switch. Just keep in mind, you don't want to make it more complicated than it needs to be, that tends to happen with if's and switches. :wink:

If every member of this board donated $1 to the dev team, that would be over $11,000.00. Don't you think this cart is worth at least a $1????

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...