A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

How to implement the customized order promotion

Vote:
 

Hi Team,

How to implement the custom order promotion. 

Advance thanks,

Please share sample code 

Edit1:

Commerce version 12.5

#200825
Edited, Jan 26, 2019 8:35
Vote:
 

First Create your Custom Order Content type and add your custom properties

[ContentType(GUID = "9ef12797-913d-46c4-87a7-ceecdd62081c")]
 public class MyOrderDiscountPromotion : OrderPromotion
 {
 /// <summary>
 /// The percent of amount off the order.
 /// </summary>
 public virtual decimal Discount { get; set; }
}

Then create a processor which is called by the promotion engine to apply the promotion

public class MyOrderDiscountPromotionProcessor : OrderPromotionProcessorBase<MyOrderDiscountPromotion>
{
 public override RewardDescription Evaluate(MyOrderDiscountPromotion promotionData, PromotionProcessorContext context)
 {
 throw new NotImplementedException();
 }

 protected override bool CanBeFulfilled(MyOrderDiscountPromotion promotionData, PromotionProcessorContext context)
 {
 throw new NotImplementedException();
 }

 protected override PromotionItems GetPromotionItems(MyOrderDiscountPromotion promotionData)
 {
 throw new NotImplementedException();
 }
}

The PromotionProcessorContext contains all information from the “context” we need to evaluate the promotion.

Hope this is enough to get you started.

#200826
Jan 26, 2019 15:59
Vote:
 

Thanks Johnny,

#200827
Jan 26, 2019 17:01
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.