Skip to content

Instantly share code, notes, and snippets.

@lrkwz
Last active June 6, 2023 18:01
Show Gist options
  • Save lrkwz/9668137 to your computer and use it in GitHub Desktop.
Save lrkwz/9668137 to your computer and use it in GitHub Desktop.
Magento quantity dropdown
<?php if ( Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getEnableQtyIncrements() ){ ?>
<select class="input-text qty" name="qty" id="qty">
<?php $i = (Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMinSaleQty()?Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMinSaleQty():1); ?>
<?php do { ?>
<option value="<?php echo $i?>">
<?php echo $i?>
<?php $i+= Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQtyIncrements() ?>
</option>
<?php } while ($i <= (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getMaxSaleQty()) ?>
</select>
<?php } else { ?>
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
<?php } ?>
@lrkwz
Copy link
Author

lrkwz commented Mar 21, 2014

This should go into

app/design/frontend/PACKAGE_NAME/THEME_NAME/template/catalog/product/view/addtocart.phtml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment