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:
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
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.
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.
Seems to be just
IContentLoader.Get<PromotionData>(promotionGuid)
if that was your question?
YEs, that was exactly my question. And I have searched for this so much, but couldn't find anything.
Will try this.
Thank you!
Oh sorry! I lied. Actually how do we get the percentage value from this object is the question.
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.
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
Quan
To make sure I understand, we are using epi promotion. Nothing cutomised. Do I still need to cast? Cast it to what object?
What I believe here is I need access to RewardDescription so I can get UnitPercentage Value. But unfortunately this is not acessible. I am right?
The object you're getting, PromotionData, is the base class for all promotions in epi. So it won't have anything specific. You need to find out which promotion you're using, including the epi built in, and then cast to that one, make sure it isn't null and get the values from there.
You can find a list of epi promotions in the EPiServer.Commerce.Marketing.Promotions namespace, check http://world.episerver.com/documentation/class-library/?documentId=commerce/10/C42F6B08.
Ah Okay! That would be tedious though to check for each promotion type. It can be any promotion.
Will try it to work with that. And also make sure to make it future proof (hopefully)
Thank you both!
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.