How to remove promotion code using internal id in the cart

Using this function we can remove a promotion from the cart. If the promotion is removed successfully, the cart total is updated, and the promotion no longer appears in the cart.

_.extend(CartSummaryView.prototype, {
initialize: _.wrap(CartSummaryView.prototype.initialize, function (fn) {
fn.apply(this, _.toArray(arguments).slice(1));
if (flag) {
self = this;
var promocode = this.model.get('promocodes')
if (promocode) {
if (promocode.length > 0) {
var line = _.findWhere(promocode, { code: 'SEPT-PROMO' });
		console.log(line, 'linesss')
						this.model.removePromotion(line.internalid);
}
flag = false
}
}
BackboneFormView.add(this);
}),
getContext: _.wrap(CartSummaryView.prototype.getContext, function (fn) {
var context = fn.apply(this, _.toArray(arguments).slice(1));
var promocode = this.model.get('promocodes')
var Total = context.summary.subtotal;
if (Total > 1000) {
context.showPromocodeForm = false;
}
return context
})
});

Leave a comment

Your email address will not be published. Required fields are marked *