How to remove items from the Save Later section that are not in the customer’s registered subsidiary

By using this solution we can remove the items in the customers cart page that are not available in customer registred subsidary.

_.extend(ProductListDetailsLaterView.prototype, {
		  //This function is used to hide & show the items based on subsidery in the save for later section
		  getContext: _.wrap(ProductListDetailsLaterView.prototype.getContext, function (fn) {
			  let originalRet=fn.apply(this, _.toArray(arguments).slice(1));
let profile = ProfileModel.getInstance();
		let subsidiary = profile.get("subsidiary");
		let allowedSubsidiaries = {
		  1: "custitem141",
		  17: "custitem144",
		  2: "custitem150",
		  8: "custitem146",
		  12: "custitem148",
		  11: "custitem142",
		};
			  _.each(this.model.get("items").models, (item) => {
				  if(item) {
					  let isItemAvailable=item.get('item').get(allowedSubsidiaries[subsidiary]);
					  if(!isItemAvailable) {
						  this.model.get('items').remove(item);
					  }
				  }
			  });
			  return originalRet;
		  })
		  });

Leave a comment

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