I’m trying to replace native minicart quantity field with my own ui component.
I created an override of vendor/magento/module-checkout/view/frontend/web/template/minicart/item/default.html.
My code :
<div class="details-qty qty">
<div class="field qty" data-bind="scope:'miniCartQtyUpdater', attr: {id: 'cart-item-'+item_id+'-qty'}">
<!-- ko template: getTemplate() --><!-- /ko -->
<script type="text/x-magento-init">
{
"*": {
"Magento_Ui/js/core/app": {
"components": {
"miniCartQtyUpdater": {
"component": "qtyUpdater"
"defaultQty": need to parse ko value here
}
}
}
}
}
</script>
</div>
</div>
Native code :
<label class="label" data-bind="i18n: 'Qty', attr: {
for: 'cart-item-'+item_id+'-qty'}"></label>
<input 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"
type="number"
size="4"
class="item-qty cart-item-qty">
<button data-bind="attr: {
id: 'update-cart-item-'+item_id,
'data-cart-item': item_id,
title: $t('Update')
}"
class="update-cart-item"
style="display: none">
<span data-bind="i18n: 'Update'"></span>
</button>
I need to parse ko values such as item_id, qty and product_sku to get them in my viewmodel.
How can I achieve this? Is there another way? Thanks!