Skip to content

Instantly share code, notes, and snippets.

@gelanivishal
Last active February 21, 2017 01:38
Show Gist options
  • Save gelanivishal/0c2de9aff7061e01e6a340dc6e857bed to your computer and use it in GitHub Desktop.
Save gelanivishal/0c2de9aff7061e01e6a340dc6e857bed to your computer and use it in GitHub Desktop.
How To Add Quantity drop down on Magento Product Page

Step-> 1 :: Go to app/design/frontend/base/default/template/catalog/product/view/addtocart.phtml

In the addtocart.phtml file find the following code(around line 33)

<input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>" />

Step-> 2 :: Replace with this code:

This code shows the "Available Qty for Product".

<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>

// ————————————————–OR————————————————–

// This code shows the “Maximum Qty Allowed in Shopping Cart”.

<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)->getMaxSaleQty()) ?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment