Episerver 10.8.0.0: Is there a way to retrieve the original promotion data for the promotion that is applied for a order.

Member since: 2014

Hi Can we retrive the promotion data that is saved in CMS.

When you use a promotion on a order, and if it is a percentage discount, we want to retrieve the percentage value. Liek 10% or 40%. The PromotionInformation and PromotionInformationEntry has teh dollar amount only.

#183351 Oct 11, 2017 22:52
  • Member since: 2016

    Hm. Good question.

    You can check if the applied promotion had the rewardtype "percentage" by looking at PromotionInformation.Percentage. But exactly which percentage that was used at that point in time is probably not accessable. But it's a good point, it should actually be accessible. You can do some tricky workarounds tho:

    • (not recommended) Load the promotion from PromotionInformation.PromotionGuid and read the values from there. If you change the promotion after it was applied the values will be faulty, hence why I don't recommend it.
    • (recommended) Add it yourself in the PromotionInformation.AdditionalInformation. Create your data model and serialize it to JSON and store it by registering an instance of IAdditionalPromotionInformationCreator and implementing the logic in CreateAdditionalInformation. In that you have the AdditionalPromotionInformationContext as a param where you can get the actual promotion (that was being applied, no risk of differences) in AdditionalPromotionInformationContext.PromotionData.
    #183365 Oct 12, 2017 6:31
  • Member since: 2011

    Hi,

    What would you use that information for?

    #183366 Oct 12, 2017 8:07
  • Member since: 2016

    A use case that comes to mind is the order confirmation mail, where you would want to maybe generate a "-20%" graphic from the promotion to show that you bought it during maybe some exclusive discount period or something like that. Sure, might be covered in the name/description, but if you want to do that use case you would have to extract the % from there or something

    #183367 Oct 12, 2017 8:11
  • Member since: 2014

    Joel!

    We are doing some workaround on our end. The work around we have is we calculate the percentage based on SavedAmount against the original price. But our client uses promotions heavily and they combine multiple coupons. And in seom scenarios our workaround breaks. 

    Hence we were trying to access the original data.

    Storing the promotion actual percentage with the PromotionInformation would be ideal. But for now if am able to retrieve the promotion object with promotion GUID then that would work for now as well. We can make sure the promotion doesn't change once its out there. And it usually doesn't change. We create a new one if needed.

    But  in epi 10+ there is no data in promotion  as this is stored on the  CMS side. Are we able to access this data by any means?

    We have normal carts. We are using non serialised carts.

    #183385 Oct 12, 2017 15:35
  • Member since: 2014

    Quan!

    Our client {Mud pie} has a complex bacckoffice system. They use Aprise and have their own logic of processing the orders. When an order is placed on our epi website we export these orders in text file to their apprise backoffice system.

    They have a very complex business rules for this file. And they need the actual percentage value for any promotion used in this file vs the dollar amount that epi saves. So we do need this.

    #183386 Oct 12, 2017 15:38
  • Member since: 2016

    Seems to be just 

    IContentLoader.Get<PromotionData>(promotionGuid)

    if that was your question?

    #183387 Oct 12, 2017 15:42
  • Member since: 2014

    YEs, that was exactly my question. And I have searched for this so much, but couldn't find anything.

    Will try this.

    Thank you!

    #183388 Oct 12, 2017 15:44
  • Member since: 2014

    Oh sorry! I lied. Actually how do we get the percentage value from this object is the question.

    #183389 Oct 12, 2017 15:55
  • Member since: 2011

    When you get back the PromotionData, you can try to cast it to your promotion type, and get the percentage value here.

    If you just need the percentage, store it in AdditionalInformation. But that would not be very future proof because you might need to store something else in the future.

    There is no easy, nice and future proof way here, unless you can make sure that a promotion is never changed or deleted, but disabled. 

    #183390 Oct 12, 2017 16:01
  • Member since: 2016

    Well it can be future proof if you serialize it and manage the data class in C#! You can't really change the properties in the class without migration and you'd need to do checks if it's null or not depending if it's a new property, but somewhat managable future proofiness :P

    #183391 Oct 12, 2017 16:08
First   1 2   Last