I have a table of discounts/offers, which are only applicable when meeting certain requirements. Example:Size: medium, Category: classic, Max. Ingredients: 3, Delivery: collectionMeeting these requirements results in the user having the products for a lower price (absolute price, not relative).I am thinking about the best way to implement this. Of course I could both check and define these constraints statically in the code, but do you think there could be a dynamic solution? Should each of the offers be represented by a class which implements an Offer interface?Product:- getPrice()Offer1 implements Offer:- getFinalPrice- checkForConstraintsOr am I going at this wrong? Let me know what you think.
Dynamic discounts for specific products
class design;e commerce
This is a textbook example of where compositional typing is neededProduct:-getBasePrice()IOfferConditionsType (interface):-getOfferConditionsTypeName()-matchesConditions(?)//Implement the different offer condition types, you can also implement just one Dynamic conditions type if the conditions are simple and loaded from the DBOffer:-getOfferName()-getOfferDescription()-IOfferConditionsType // you can store OfferConditionType in the DB to load different types of conditions-matchesConditions(?)  // call IOfferTypes-finalPrice(price) //this should be completely separate than matches conditions, you will  need to know the price of an offer without the conditions matching so you can advertise it