I want change qty text box into dropdown in minicart place
view/frontend/web/template/minicart/item/default.html
file.
<select data-bind="attr: {
id: 'cart-item-'+item_id+'-qty',
'data-cart-item': item_id,
'data-item-qty': qty,
'data-cart-item-id': product_sku
}, value: qty"
class="item-qty cart-item-qty">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<button data-bind="attr: {
id: 'update-cart-item-'+item_id,
'data-cart-item': item_id,
title: $t('Update')
}"
class="update-cart-item">
<span data-bind="i18n: 'Update'"></span>
</button>
I'm getting dropdown for qty.But i want to this in below format
for(i=0;i<=4;i++)
{
<option >i</option>}
How to do this.If anyone knows please explain me.
I also refer this link …
http://knockoutjs.com/documentation/options-binding.html
i don't know which file is suitable for adding script file
Best Answer
using KnockoutJS to bind array for select element
HTML Namespace_Module/view/frontend/web/template/minicart/item/default.html
XML checkout_cart_sidebar_item_renderers.xml
JS FILE: Namespace_Module/view/frontend/web/js/custom-qty.js
The result
More info about bind options to select using KnockoutJS >> KnockoutJS Document