public override bool ApplyAction(PromotionContext context, PromotionActionMode mode) { if (context == null) { return(false); } if (context.Product == null) { return(false); } decimal adjustment = 0m; switch (this.AdjustmentType) { case AmountTypes.MonetaryAmount: adjustment = Utilities.Money.GetDiscountAmount(context.UserPrice.BasePrice, this.Amount); break; case AmountTypes.Percent: adjustment = Utilities.Money.GetDiscountAmountByPercent(context.UserPrice.BasePrice, this.Amount); break; } context.UserPrice.AddAdjustment(adjustment, context.CustomerDescription); return(true); }
public override bool ApplyAction(PromotionContext context, PromotionActionMode mode) { if (context == null) { return(false); } if (context.Order == null) { return(false); } // only apply when applying to shipping areas if (mode != PromotionActionMode.ForShipping) { return(false); } decimal adjustment = 0m; switch (this.AdjustmentType) { case AmountTypes.MonetaryAmount: adjustment = Utilities.Money.GetDiscountAmount(context.Order.TotalShippingBeforeDiscounts, this.Amount); break; case AmountTypes.Percent: adjustment = Utilities.Money.GetDiscountAmountByPercent(context.Order.TotalShippingBeforeDiscounts, this.Amount); break; } context.Order.AddShippingDiscount(adjustment, context.CustomerDescription); return(true); }
public bool ApplyToOrder(MerchantTribeApplication app, Orders.Order o, Membership.CustomerAccount currentCustomer, DateTime currentDateTimeUtc, PromotionActionMode mode) { if (app == null) { return(false); } if (o == null) { return(false); } if (currentDateTimeUtc == null) { return(false); } PromotionContext context = new PromotionContext(app, o, currentCustomer, currentDateTimeUtc); context.CustomerDescription = this.CustomerDescription; // Make sure we have an active promotion before applying if (GetStatus(context.CurrentDateAndTimeUtc) != PromotionStatus.Active) { return(false); } // Make sure we meet all requirements // NOTE: we order by processing cost which should allow us to check // the fastest items first. For example, checking userID is faster // than checking user group because ID is in the context and group // requires a database call. foreach (IPromotionQualification q in this._Qualifications.OrderBy(y => y.ProcessingCost)) { if (!q.MeetsQualification(context)) { return(false); } } // We're qualified, do actions foreach (IPromotionAction a in this._Actions) { a.ApplyAction(context, mode); } return(true); }
private void ApplyOffersToOrder(Order o, PromotionActionMode mode) { if (o == null) { return; } Membership.CustomerAccount currentUser = null; if (o.UserID != string.Empty) { currentUser = _app.MembershipServices.Customers.Find(o.UserID); } List <Marketing.Promotion> offers = _app.MarketingServices.Promotions.FindAllPotentiallyActiveOffers(DateTime.UtcNow); foreach (Marketing.Promotion offer in offers) { offer.ApplyToOrder(_app, o, currentUser, DateTime.UtcNow, mode); } }
public override bool ApplyAction(PromotionContext context, PromotionActionMode mode) { if (context == null) return false; if (context.Product == null) return false; decimal adjustment = 0m; switch(this.AdjustmentType) { case AmountTypes.MonetaryAmount: adjustment = Utilities.Money.GetDiscountAmount(context.UserPrice.BasePrice, this.Amount); break; case AmountTypes.Percent: adjustment = Utilities.Money.GetDiscountAmountByPercent(context.UserPrice.BasePrice, this.Amount); break; } context.UserPrice.AddAdjustment(adjustment, context.CustomerDescription); return true; }
public override bool ApplyAction(PromotionContext context, PromotionActionMode mode) { if (context == null) return false; if (context.Order == null) return false; // only apply when applying to shipping areas if (mode != PromotionActionMode.ForShipping) return false; decimal adjustment = 0m; switch(this.AdjustmentType) { case AmountTypes.MonetaryAmount: adjustment = Utilities.Money.GetDiscountAmount(context.Order.TotalShippingBeforeDiscounts, this.Amount); break; case AmountTypes.Percent: adjustment = Utilities.Money.GetDiscountAmountByPercent(context.Order.TotalShippingBeforeDiscounts, this.Amount); break; } context.Order.AddShippingDiscount(adjustment, context.CustomerDescription); return true; }
public bool ApplyToOrder(MerchantTribeApplication app, Orders.Order o, Membership.CustomerAccount currentCustomer, DateTime currentDateTimeUtc, PromotionActionMode mode) { if (app == null) return false; if (o == null) return false; if (currentDateTimeUtc == null) return false; PromotionContext context = new PromotionContext(app, o, currentCustomer, currentDateTimeUtc); context.CustomerDescription = this.CustomerDescription; // Make sure we have an active promotion before applying if (GetStatus(context.CurrentDateAndTimeUtc) != PromotionStatus.Active) return false; // Make sure we meet all requirements // NOTE: we order by processing cost which should allow us to check // the fastest items first. For example, checking userID is faster // than checking user group because ID is in the context and group // requires a database call. foreach (IPromotionQualification q in this._Qualifications.OrderBy(y => y.ProcessingCost)) { if (!q.MeetsQualification(context)) return false; } // We're qualified, do actions foreach (IPromotionAction a in this._Actions) { a.ApplyAction(context, mode); } return true; }
private void ApplyOffersToOrder(Order o, PromotionActionMode mode) { if (o == null) return; Membership.CustomerAccount currentUser = null; if (o.UserID != string.Empty) currentUser = _app.MembershipServices.Customers.Find(o.UserID); List<Marketing.Promotion> offers = _app.MarketingServices.Promotions.FindAllPotentiallyActiveOffers(DateTime.UtcNow); foreach (Marketing.Promotion offer in offers) { offer.ApplyToOrder(_app, o, currentUser, DateTime.UtcNow, mode); } }
public virtual bool ApplyAction(PromotionContext context, PromotionActionMode mode) { return false; }
public virtual bool ApplyAction(PromotionContext context, PromotionActionMode mode) { return(false); }