0

I want to add dropdown of 1 to 10 of quantity at cart page and if customer choose the 10 from quantity dropdown then the textbox appears for quantity field.

please help me. thank you.

1 Answer 1

0

Go to cart page .phtml file and add below code.

<div class="field qty">
   <label class="label" for="qty">
       <span><?= /* @escapeNotVerified */ __('Qty') ?></span>
   </label>
   <div class="control">
       <select name="qty" id="qty" title="<?php echo __('Qty') ?>" class="cart-qty">
            <?php for ($i = 1; $i <= 10; $i++): ?>
                <option value="<?php echo $i ?>"><?php echo $i ?></option>
            <?php endfor; ?>
        </select>
        <input type="text" id="special-quantity" class="special-quantity" name="qty" style="display:none;">
    </div>
</div>


<script>
    require(['jquery'], function($) {
        $(document).ready(function() {
            $('.cart-qty').change(function() {
                if ($(this).val() == '10') {
                    $('#special-quantity').show();
                } else {
                    $('#special-quantity').hide();
                }
            });
        });
    });
</script>

Let me know if any quries.

Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.