Question

How can I replace the text field for user definable quantities on bundle products with a dropdown menu?

Example here: https://www.sconch.com/test-bundle - see Test Item 1

I've managed to replace all other quantity fields with dropdowns but can't work out how to do it for the constituent parts of bundle products

Thanks,

Hugh

Was it helpful?

Solution

The way to achieve this is to edit the following files:

/app/design/frontend/[YOUR_THEME]/[YOUR_CHILD]/template/bundle/catalog/product/view/type/bundle/option/radio.phtml

/app/design/frontend/[YOUR_THEME]/[YOUR_CHILD]/template/bundle/catalog/product/view/type/bundle/option/select.phtml

You need to find the line that looks like this (this may be slightly different depending on your theme):

<input class="txtIn qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>" onkeyup="bundle.changeOptionQty(this, event)" onblur="bundle.changeOptionQty(this, event)" <?php if (!$_canChangeQty) echo ' disabled="disabled"' ?> id="bundle-option-<?php echo $_option->getId() ?>-qty-input" type="text" name="bundle_option_qty[<?php echo $_option->getId() ?>]" value="<?php echo $_defaultQty ?>" />

and replace with:

<?php if (!$_canChangeQty): ?> <input class="txtIn qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>" onkeyup="bundle.changeOptionQty(this, event)" onblur="bundle.changeOptionQty(this, event)" <?php if (!$_canChangeQty) echo ' disabled="disabled"' ?> id="bundle-option-<?php echo $_option->getId() ?>-qty-input" type="text" name="bundle_option_qty[<?php echo $_option->getId() ?>]" value="<?php echo $_defaultQty ?>" /> <?php else: ?> <select class="txtIn qty" onclick="bundle.changeOptionQty(this, event)" onkeyup="bundle.changeOptionQty(this, event)" onblur="bundle.changeOptionQty(this, event)" id="bundle-option-<?php echo $_option->getId() ?>-qty-input" type="select" name="bundle_option_qty[<?php echo $_option->getId() ?>]" > <?php if (!$_option->getRequired()): ?> <option value="0">0</option> <?php endif; ?> <option value="1" <?php if ($_defaultQty=='1'): ?>selected<?php endif; ?>>1</option> <option value="2" <?php if ($_defaultQty=='2'): ?>selected<?php endif; ?>>2</option> <option value="3" <?php if ($_defaultQty=='3'): ?>selected<?php endif; ?>>3</option> <option value="4" <?php if ($_defaultQty=='4'): ?>selected<?php endif; ?>>4</option> <option value="5" <?php if ($_defaultQty=='5'): ?>selected<?php endif; ?>>5</option> <option value="6" <?php if ($_defaultQty=='6'): ?>selected<?php endif; ?>>6</option> <option value="7" <?php if ($_defaultQty=='7'): ?>selected<?php endif; ?>>7</option> <option value="8" <?php if ($_defaultQty=='8'): ?>selected<?php endif; ?>>8</option> <option value="9" <?php if ($_defaultQty=='9'): ?>selected<?php endif; ?>>9</option> <option value="10" <?php if ($_defaultQty=='10'): ?>selected<?php endif; ?>>10</option> <option value="11" <?php if ($_defaultQty=='11'): ?>selected<?php endif; ?>>11</option> <option value="12" <?php if ($_defaultQty=='12'): ?>selected<?php endif; ?>>12</option> <option value="13" <?php if ($_defaultQty=='13'): ?>selected<?php endif; ?>>13</option> <option value="14" <?php if ($_defaultQty=='14'): ?>selected<?php endif; ?>>14</option> <option value="15" <?php if ($_defaultQty=='15'): ?>selected<?php endif; ?>>15</option> <option value="16" <?php if ($_defaultQty=='16'): ?>selected<?php endif; ?>>16</option> <option value="17" <?php if ($_defaultQty=='17'): ?>selected<?php endif; ?>>17</option> <option value="18" <?php if ($_defaultQty=='18'): ?>selected<?php endif; ?>>18</option> <option value="19" <?php if ($_defaultQty=='19'): ?>selected<?php endif; ?>>19</option> <option value="20" <?php if ($_defaultQty=='20'): ?>selected<?php endif; ?>>20</option> </select> <?php endif; ?>

As you will see, this looks to see if the quantity can actually be changed and, if it can, uses a dropdown menu with quantities 0-20. The if statement around the 0 ensures that 0 is only available if the item is not a required item in the bundle.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top