How do I change the Quantity text input box to a dropdown on configurable products?
I've got this piece of code in my /catalog/product/view/addtocart.phtml file
<label for="qty"><?php echo $this->__('Quantity') ?></label>
<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>
</div>
<?php endif; ?>
This works well for the simple products, showing 1 to however many items I have in stock. But on configurable products, it only shows '1' in the dropdown. (likely because the configurable product itself doesn't have inventory)
I saw this stackexchange page, but haven't been able to adapt it to what I want.
Edit: Here's a use case -
Say I've got boots available in four sizes.
Boots:
Size 6 - 3 pairs
Size 7 - 2 pairs
Size 8 - 1 pair
Size 9 - 4 pairs
When I select "Size 6," I'd like the Quantity dropdown to be 1-3. If I select size 9, it should go up to 4.