Badges are used for displaying any special message for any item, for example to display the “NEW ARRIVAL” of an item or the “DISCOUNT” on any item. Here we are creating a badge for the items present in the cart page.
Steps:
1. Create a new extension for Cart item badge.
2. Create a custom field in Item records, of the type freeform text.
3. Display the value of the custom field in Cart.
_.extend(CartLinesView.prototype, {
getContext: _.wrap(CartLinesView.prototype.getContext, function(fn) {
try{
console.log('this', this)
var original = fn.apply(this,_.toArray(arguments).slice(1));
var badge=this.model.attributes.item.attributes.custitemcartitembadge1;
original.badge = badge;
console.log(badge)
}catch(e) {
console.log("err@barcode2View",e);
}
return original
})
});