Hello, i do some changes in my view-cart layout in order to looks like in capture. For that i replace quantity_box.twig with my new implementation.
This is my own quantity_box.twig file
HTML Code:
{##
# Main element (input)
#
# @ListChild (list="product.quantity-box", weight="20")
#}
<div class="fdmteam_quantity">
<input type="hidden" class="{{ this.getClass() }}" id="{{ this.getBoxId() }}" value="{{ this.getBoxValue() }}" name="{{ this.getBoxName() }}" >
<span class="fdmteam_quantity_value" id="count-{{ this.getBoxId() }}">
{{ this.getBoxValue() }}
</span>
<span class="fdmteam_quantity_label">
{{ t(this.getBoxTitle()) }}
</span>
</div>
<div class="fdmteam_quantity_plus" id="plus-{{ this.getBoxId() }}"></div>
<div class="fdmteam_quantity_minus" id="minus-{{ this.getBoxId() }}"></div>
<script>
document.body.addEventListener('click', function(event){
var _target_p = "plus-{{ this.getBoxId() }}" ;
var _target_m = "minus-{{ this.getBoxId() }}" ;
var _input = "{{ this.getBoxId() }}";
var _span = "count-{{ this.getBoxId() }}";
if(event.target.id == _target_p){
var i = parseInt(document.getElementById(_input).value) ;
i++;
document.getElementById(_span).innerHTML = i;
document.getElementById(_input).value = i;
// do update cart !!
}else if(event.target.id == _target_m){
var i = parseInt(document.getElementById(_input).value) ;
i--;
if(!i){
return false;
}else{
document.getElementById(_span).innerHTML = i;
document.getElementById(_input).value = i;
// do update cart !!
}
}
});
</script>
The question is how to put updateCart trigger in order to work properly as default implementation. I want to update quantity of item when i press + - button.