Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

quantity box on product_info.php


joyces

Recommended Posts

Hi

Feel a bit stupid over this but any of you php geniusses that could help would really appreciate it.

 

Have spent a very fraught week moving to a new dedicated server and eventually thought I had cracked it. My site is near to going live but I have found one problem that has me stumped. I have quite a lot of brilliant conts so php heavily modified. On the product_info.php I have added a cont to include MRSP and Quantity but I did these a long time ago and everything was working fine but since the move I cant add anything to the shopping cart from this page.

 

Have been playing about with the code and I think I have identified the problem as the bit "$HTTP_POST_VARS['id']))+$quantity" in application_top. If I change this back to "$HTTP_POST_VARS['id']))+1" then I can add to the shopping cart but only one at a time. I also have the quantity box on the product_listings.php and that works no probs.

 

Can anyone sort this out for me? have read loads of posts and although found someone with the same problem they never got an answer.

Have included what i think is relevent code for both product_info.php and application_top.php below.

I'm at the point of begging, please if you have any ideas can you help.

Thanks

Andrea

 

product_info.php

 <td class="main" align="right"><?php echo 'Quantity';?><input type="text" name="quantity" value="1" maxlength="2" size="2"></td>
               <td class="main" align="right" width="1px"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
             </tr>
           </table></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
     <tr>
       <td>
<?php
   if ((USE_CACHE == 'true') && empty($SID)) {
     echo tep_cache_also_purchased(3600);
   } else {
     include(DIR_WS_MODULES . FILENAME_ALSO_PURCHASED_PRODUCTS);
   }
 }
?>
       </td>
     </tr>
   </table></form></td>

 

application_top.php

// customer adds a product from the products page
     case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                               $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+$quantity , $HTTP_POST_VARS['id']);
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;
						  case 'buy_now_form' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                              $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+($HTTP_POST_VARS['cart_quantity']), $HTTP_POST_VARS['id']);
// replace quantities         $cart->get_quantity($HTTP_POST_VARS['products_id'])-($cart->get_quantity($HTTP_POST_VARS['products_id']))+($HTTP_POST_VARS['cart_quantity']), $HTTP_POST_VARS['id']);
                              }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;
     // customer adds multiple products from the products_listing page
   case 'add_multiple' :    
                             while ( list( $key, $val ) = each( $HTTP_POST_VARS ) ) 
                                { 
                                if (substr($key,0,11) == "Qty_ProdId_" || substr($key,0,11) == "Qty_NPrdId_") 
                                { 
                                $prodId = substr($key, 11); 
                                $qty = $val; 
                                if ($qty <= 0 ) continue; 
                               if(isset($HTTP_POST_VARS["id_$prodId"]) && is_array($HTTP_POST_VARS["id_$prodId"])) {
                                  // We have attributes
                                  $cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId,$HTTP_POST_VARS["id_$prodId"]))+$qty, $HTTP_POST_VARS["id_$prodId"]);
                                } else {
                                  // No attributes
                                  $cart->add_cart($prodId, $cart->get_quantity($prodId)+$qty);
                                }
                               } 
                             } 
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;

Link to comment
Share on other sites

Hi

Ok figured it out!

For anyone with the same problem, some conts and some posts I have fouud say to change application top from

$HTTP_POST_VARS['id']))+1 to $HTTP_POST_VARS['id']))+$quantity

but if you change it to

$HTTP_POST_VARS['id']))+$HTTP_POST_VARS['quantity']

it works.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...