Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Update: this is out of date. The replacement: Dynamics Retail Discount Extensibility – Multiple ISVs
We have some code snippets of how to register your new discount type.
Customized retail discount store
public class CustomizedRetailDiscountStore : RetailDiscountStore<br> {<br> protected override DiscountBase CreateDiscount(PeriodicDiscount discountAndLine)<br> {<br> if ((int)discountAndLine.PeriodicDiscountType == TeaserDiscount.PeriodicDiscountOfferTypeTeaser)<br> {<br> return new TeaserDiscount(discountAndLine.ValidationPeriod);<br> }<br> else if (discountAndLine.PeriodicDiscountType == PeriodicDiscountOfferType.Offer)<br> {<br> object quantityLimitObject = discountAndLine.GetProperty(ExtensionDiscountOfferQuantityLimitString);<br> if (quantityLimitObject != null)<br> {<br> int quantityLimit = (int)quantityLimitObject;<br> if (quantityLimit > 0)<br> {<br> return new OfferDiscountWithQuantityControl(discountAndLine.ValidationPeriod, quantityLimit);<br> }<br> }<br> return new OfferDiscountWithLineFilter(discountAndLine.ValidationPeriod);<br> }<br> else<br> {<br> return base.CreateDiscount(discountAndLine);<br> }<br> }<br> protected override RetailDiscountLine CreateRetailDiscountLine(<br> PeriodicDiscount discountAndLine,<br> DiscountBase discount)<br> {<br> RetailDiscountLine retailDiscountLine = base.CreateRetailDiscountLine(discountAndLine, discount);<br> ValidationPeriod lineValidationPeriod = discountAndLine.GetProperty(ExtensionLinePeriodString) as ValidationPeriod;<br> if (lineValidationPeriod != null)<br> {<br> retailDiscountLine.SetProperty(ExtensionLinePeriodString, lineValidationPeriod);<br> }<br> return retailDiscountLine;<br> }<br> }
Register customized retail discount store
At the top of the customized pricing service call, register the customized retail discount store.
public class PricingServiceSampleCustomization : IRequestHandler<br> {<br> public Response Execute(Request request)<br> {<br> // Register customized components here.<br> if (!PricingEngineExtensionRepository.IsInitialized)<br> {<br> PricingEngineExtensionRepository.RegisterRetailDiscountStore(new CustomizedRetailDiscountStore());<br> PricingEngineExtensionRepository.IsInitialized = true;<br> }<br> …<br> }<br> }
Related: Dynamics Retail Discount Extensibility Overall Approach
Related: Dynamics Retail Discount Extensibility – Three Discount Categories
Please sign in to use this experience.
Sign in