I want to split the quantity text box into three text boxes,i.e., for child, adult and others separatly before add to cart for only bundled products. I did by adding the following code in the addtocart.phtml

 <?php if ($_product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE): ?>
            <label for="qty"><?php echo $this->__('Adult Qty:') ?></label>
            <input type="text" name="qty" id="adult-qty" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
            <label for="qty"><?php echo $this->__('Child Qty:') ?></label>
            <input type="text" name="qty" id="child-qty" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
            <label for="qty"><?php echo $this->__('Infant Qty:') ?></label>
            <input type="text" name="qty" id="infant-qty" maxlength="12" value="1" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
        <?php endif; ?>

Now what i need is have to add these three quantities and save as a total quantity. Also have to view child,adult and others quantities separately in teh shopping cart page. Can anyone have idea on this?

  • What is the usecase? – user487772 May 15 '14 at 15:29
  • Have to store the total quantity of these 3 quantities into database and have to give the splittable view to the users – Kalai May 15 '14 at 15:40
  • JavaScript then – user487772 May 15 '14 at 16:21
  • Yes by using js we can add it and insert into the DB. But how to split it and view in next page without storing them separately into the DB? – Kalai May 15 '14 at 16:24
  • Also if change the quantity by using jquery while typing the quantity text boxes getting the following error. "Item qty declaration error." – Kalai May 15 '14 at 16:35

Vinai gave a great answer on this:


What you want to do is use JS to calculate the qty and put it into a hidden field. The different quantities can just be saved in three different attributes for quote_item or as a json string, whatever suits you.

You don't need to transfer it to the order_item if you don't need it in backend, order confirmation or to buy the stuff again. If you need one of those, you have to implement the whole observer logic for orders too.

| improve this answer | |

It looks to me that you're trying to implement functionality already in place -- grouped products:


I have to admit that using bundled products as group elements might not work, but I'm pretty confident that overcoming this obstacle is much easier than implementing something else.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.