0
votes

I am using Magento ver. 1.9.2.1

I just want to show quantity in dropdown for simple and configurable products in product view page and cart page as well.

I replace code in app/design/frontend/rwd/default/template/catalog/product/view/addtocart.phtml page

Replace below code

<input class="qty-decrease" value="-" type="button" onclick="var qty_el = document.getElementById('qty'); var qty = qty_el.value; if( !isNaN( qty ) && qty > 1 ) qty_el.value--;return false;">
            <input id="qty" class="input-text qty" type="text" maxlength="12" title="<?php echo $this->__('Qty') ?>" size="4" value="1" name="qty" style="padding-top: 0;">
<input class="qty-increase"  value="+" type="button" onclick="var qty_el = document.getElementById('qty'); var qty = qty_el.value; if( !isNaN( qty )) qty_el.value++;return false;">

to

<select class="input-text qty" name="qty" id="qty">
<?php $i = 1 ?>
<?php do { ?>
<option value="<?php echo $i?>">
<?php echo $i?>
<?php $i++ ?>
</option>
<?php } while ($i <= (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()) ?>
</select>

It is working fine for simple product but in configurable product, options are not showing. And in cart page I am unable to see anything for both types of products.

1

1 Answers

0
votes

In configurable product qty is not their own, In configurable product qty come from associated product so you have to put condition for configurable product if configurable product found then you have to get qty from their associated product instead of configurable product.