Guest Posted July 7, 2008 Posted July 7, 2008 Hi Please can some one help!! I am trying to add a quantity box to the product_info.php Sounds easy?? I have found the item (Listed below) in the tips & tricks page , but it always adds the product_id number as the quantity. IE: product_id=41 so 41 items are added to the shopping cart. Can anyone help. ----------------------------------------------------------------------------------------------------------------------------------- Add Quantity Box to Products Page Last Update: 17th August, 2005 Article ID: 246 Introduction Solution Introduction This code can be added in the product_info.php page to add a quantity box for customers when ordering. Solution Find this code in product_info.php: <td class="main" align="right"><?php echo osc_draw_hidden_field('products_id', $Qproduct->valueInt('products_id')) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td> and after the php code and before the </td> add: <input type="text" name="quantity" value="1" maxlength="2" size="2"> It will look like this and puts the quantity box to the right of the "add to cart" graphic button: <td class="main" align="right"><?php echo osc_draw_hidden_field('products_id', $Qproduct->valueInt('products_id')) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?><input type="text" name="quantity" value="1" maxlength="2" size="2"></td> Then in includes\application_top.php around line 143 find this code: $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+1, $_POST['id']); Replace with this one $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$_POST['products_id'], $_POST['id']); Quote
lindsayanng Posted July 7, 2008 Posted July 7, 2008 Try changing this <?php echo osc_draw_hidden_field('products_id', $Qproduct->valueInt('products_id')) to this php echo osc_draw_hidden_field('products_id', $Qproduct->valueInt('products_qty')) if that does work try this: Contribution for QTY in product listing Quote A great place for newbies to start Road Map to oscommerce File Structure DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways! HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you Proud Memeber of the CODE BREAKERS CLUB!!
Guest Posted July 7, 2008 Posted July 7, 2008 Thanks Lyndsey My coding look a little differant as below.. ------------------------------------------------------------------------------------------------------------ <td class="main" align="right"> <?php echo tep_draw_hidden_field('products_id', $product_info['products_qty']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?> <input type="text" name="quantity" value="1" maxlenght="2" size="2"> ---------------------------------------------------------------------------------------------------- as you can see i have change it to products_qty but the results are the same.. I will take a look at your other suggestion. Any more idears will always be appreciated. Thanks TONY Try changing this <?php echo osc_draw_hidden_field('products_id', $Qproduct->valueInt('products_id')) to this php echo osc_draw_hidden_field('products_id', $Qproduct->valueInt('products_qty')) if that does work try this: Contribution for QTY in product listing Quote
Guest Posted July 7, 2008 Posted July 7, 2008 Thanks Burt Work Fine....Sorry I did`nt spot that .. Tony $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$_POST['products_id'], $_POST['id']); Surely you can see the problem here?? Should be: $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$_POST['quantity'], $_POST['id']); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.