Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quantity Field contribution


Guest

Recommended Posts

I installed the quantity field contirubtion to allow customers to select the quantity from product_info.php. The contribution said to change line 213 from;

<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

to;

<td class="main" align="right"><?php echo TEXT_QUANTITY . tep_draw_input_field('quantity', '1', 'SIZE=2 maxlength=2') . tep_draw_separator('pixel_trans.gif', '5', '1') . tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'align=absmiddle'); ?></td>

 

This places the quantity box right beside the "Add To Cart" button which I though looked terrible .... so my problems begin.

 

I changed the above line back to its original state and created a new line;

              <td class="main"><?php echo TEXT_QUANTITY . ' ' . tep_draw_input_field('quantity', '1', 'SIZE=2 maxlength=2') . tep_draw_separator('pixel_trans.gif', '5', '1'); ?></td>

 

and placed it at line 157;

        if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }
?>
           <tr>
             <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
             <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>
==>           <td class="main"><?php echo TEXT_QUANTITY . ' ' . tep_draw_input_field('quantity', '1', 'SIZE=2 maxlength=2') . tep_draw_separator('pixel_trans.gif', '5', '1'); ?></td>
           </tr>

 

Now the problem is, when I have a product that has an attribute such as here it works perfectly (you can add to the cart and the quantity shows up). But when the product has no attribute such as here there is no quantity box and you can NOT add the product to the cart.

 

I think I have the right code, just in the wrong place :( . I would like this to work but be able to keep the quantity box where it is on the page.

 

Any help would be appreciated.

 

Peter :D

Link to comment
Share on other sites

The prob, I think, Peter is having the quantity box within the product attribute IF clause.

 

Try moving it outside of that.

Edited by yesudo

Your online success is Paramount.

Link to comment
Share on other sites

I have some allignment to do but it is working, thank you once again. :)

 

Peter

 

        if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }
?>
           <tr>
             <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
             <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>
           </tr>
<?php
     }

?>
         </table>

<?php
   }
?>
<tr>
             <td class="main"><?php echo TEXT_QUANTITY . ' ' . tep_draw_input_field('quantity', '1', 'SIZE=2 maxlength=2') . tep_draw_separator('pixel_trans.gif', '5', '1'); ?></td>
<td>

Link to comment
Share on other sites

  • 5 months later...

I installed the quantity field contirubtion to allow customers to select the quantity from product_info.php. The contribution said to change line 213 from;

<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

to;

<td class="main" align="right"><?php echo TEXT_QUANTITY . tep_draw_input_field('quantity', '1', 'SIZE=2 maxlength=2') . tep_draw_separator('pixel_trans.gif', '5', '1') . tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'align=absmiddle'); ?></td>

 

I have changed the code as above and even though I agree that it doesn't look so good I dont mind if I can get it to work. The Text "Quantity" is there ok, but if I make the qty 2 and "add to cart" it shows 1. even if i update. If I go back and change it to 4 then "add to cart" I get 2 ????.

 

I have the added problem of not only being a novice but the background to the "Whats in my cart" is white so I didn't know that I could change the qty at that stage as there is no box around the field.

 

The site is http://www.lannagifts.com

 

Can anybody help

 

+++++Tired, red eyed and stupid+++++ :lol:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...