How to Extend AdditionalFilters
Overview
AdditionalFilters is the way to extend StandardFilter (filters to apply to get the discounts). With this functionality filters can be created dynamically, adding more flexibility. These filters are used to apply discounts in the WebPOS. Find more information about discounts&promotions.
The output of generateFilter must be a non-empty string starting with the word AND with also a starting space.
Example
This example shows how to create additional filters.
OB.Model.Discounts.additionalFilters.push({ generateFilter: function (receipt) { var currentCoupons = "", i, filter = ""; if (receipt.get('coupons')) { for (i = 0; i < receipt.get('coupons').length; i++) { if (i !== 0) { currentCoupons += ","; } currentCoupons += "'" + receipt.get('coupons')[i].offerid + "'"; } } filter = "and (M_Offer.EM_OBDISCP_ISCOUPON !='true'"; if (currentCoupons !== "") { filter += " or M_Offer.M_Offer_Id in (" + currentCoupons + ")) " } else { filter += ")"; } return filter; } });