in app/design/frontend/default/<TEMPLATE>/template/checkout/cart/item/default.phtml:

<td class=”a-center”>
<input name=”cart[<?php echo $_item->getId() ?>][qty]” value=”<?php echo $this->getQty() ?>” size=”4″ title=”<?php echo $this->__(‘Qty’) ?>” class=”input-text qty” maxlength=”12″ />
<select class=”input-text qty” name=”cart[<?php echo $_item->getId() ?>][qty]” id=”qty”>
<?php
// show dropdown instead of textfield in cart
$total = Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($this->getProduct())->getQty();
for ($x=10; $x<=$total; $x++) {
$selected = ”;
if ($x == $this->getQty()) {
$selected .= ‘ selected=”selected”‘;
}
echo ‘<option value=”‘ . $x . ‘”‘ . $selected . ‘>’ . $x . ‘</option>’;
}
?>
</select>
</td>

By admin

One thought on “How to have a dropdown for the quantity in magento”

Leave a Reply

Your email address will not be published. Required fields are marked *