Rather than having input box, I would like to place dropdown for product qty to add to cart. So to do this, I've done the following:
In my
\app\design\frontend\Vendor\Theme\Magento_Catalog\templates\product\view\addtocart.phtml
I've replaced following code instead of input box.
<select name="qty" id="qty" title="<?php /* @escapeNotVerified */ echo __('Qty') ?>"
class="input-text qty" data-validate="<?php echo $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>">
<?php $i = 1 ; ?>
<?php
while( $i < 5) { ?>
<option value="<?php echo $block->getProductDefaultQty() * $i; ?>"><?php echo $block->getProductDefaultQty() * $i; ?></option>
<?php $i++; ?>
<?php } ?>
</select>
<button type="submit"
title="<?php /* @escapeNotVerified */ echo $buttonTitle ?>"
class="btn btn-orange"
id="product-addtocart-button">
<span><?php /* @escapeNotVerified */ echo $buttonTitle ?></span>
</button>
But it's not adding the product into the cart.
Can anyone help me to build dropbox
instead of textbox
for adding product to the cart?