Tuesday, October 1, 2013

Magento replace quantity text box to select box

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) ?>" />



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>


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>

No comments:

Post a Comment

Please mention your comments.......