create the extension we can increase and decrease the quantity of the item in the cart or checkout by applying a data-actions
Entry point:
_.extend(TransactionLineViewsCellNavigableView.prototype, {
events: {
'click [data-action="plus"]': 'addQuantity',
'click [data-action="minus"]': 'subQuantity'
},
getContext: _.wrap(TransactionLineViewsCellNavigableView.prototype.getContext, function (fn) {
var original = fn.apply(this, _.toArray(arguments).slice(1));
console.log(original);
itemId = original.itemId
return original
}),
/*function is used for increase item */
addQuantity: function addQuantity (e){
console.log("this", this)
var cart = container.getComponent('Cart');
cart.addLine({
line: {
quantity: 1,
item: {
internalid:itemId
}
}
})
},
/*function is used for decrease item */
subQuantity: function subQuantity (e){
// console.log("this", this)
var cart = container.getComponent('Cart');
cart.addLine({
line: {
quantity: -1,
item: {
internalid:itemId
}
}
})
},
})
In tpl give the corresponding data action
Example :<div class=”minus” id=”minus” data-action=”minus”>-</div>