November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hey,
Firstly, a tip, you can click on the </> icon in the editor here to get it C# formatted, it was quite a pain to read! :D
Looked through the code and couldn't find anything directly wrong, so just to double check that every requirement for it to be active is there:
You should be seeing a call to CanBeFulfilled when you do the IPromotionEngine.Run, if the PromotionEngine thinks your promotion is active.
Joel,
Thanks for the formatting tip. I'll make sure I use that next time.
One of the items on your checklist solved the problem - it now breaks in the processor - in the CanBeFulfilled function as you mentioned.
I had the campaign market set to the default market (which is what it is in the commerce manager) but when I changed it to ALL markets, it started
to work.
Thanks for your help.
Jeroen, the processor is in the copy pasted code, albeit a bit hidden due to formatting! :)
Glad it worked! I get the question "why isn't this discount working" a fair bit, so I'm pretty familiar with the resolutions.
Hi,
I have defined a custom promotion in this manner (please ignore many spaces being stripped out - pasting into this site did this):
[ContentType(DisplayName = "Legacy Entry Promotion",
GUID = "1b2554c6-9f4c-4bb4-abe4-c5dce9c89c95",
AvailableInEditMode = false,
Description = "Used for defining a legacy entry promotion")]
[AdministrationSettings(CodeOnly = true, GroupName = "Marketing")]
[SiteImageUrl(ContentPaths.TemplateIconsFolderPath + "LegacyPromotions-logo-color.png")]
publicclassLegacyEntryPromotion : EntryPromotion
{
[Required]
[BackingType(typeof(PropertyNumber))]
[Enum(typeof(CommerceListValues.PromotionRestrictedToCommerceTransactionType))]
[Display(
Name = "Promotion is restricted to selected product",
Description = "Promotion is restricted to selected product",
Order = 100)]
publicvirtualCommerceListValues.PromotionRestrictedToCommerceTransactionType PromotionRestrictedToCommerceTransactionType { get; set; }
[Required]
[UIHint(UIHint.Textarea)]
[Display(
Name = "Markup for Product Page",
Description = "This is the HTML that gets displayed on the site, on an event page, or a membership page etc.",
Order = 200)]
publicvirtualXhtmlString MarkupForProductPage { get; set; }
[UIHint(UIHint.Textarea)]
[Display(
Name = "Markup for Linked Promo In Checkout",
Description = "This is the HTML that gets displayed to alert the user to the promo during the checkout process. If blank we use the Product Page HTML.",
Order = 300)]
publicvirtualXhtmlString MarkupForLinkedPromoInCheckout { get; set; }
[Required]
[BackingType(typeof(PropertyNumber))]
[Enum(typeof(CommerceListValues.PromotionType))]
[Display(
Name = "Promotion Type",
Description = "What promotion logic is used. If Linked, the promo applies only if all relations are present in the basket. Otherwise it applies to any related product independently.",
Order = 400)]
publicvirtualCommerceListValues.PromotionType PromotionType { get; set; }
//[PromotionRegion(PromotionRegionName.Discount)]
[Display(
Name = "Discount",
Description = "Depending on the Promotion Type chosen above, this will either be a percentage discount (e.g., 25) or an absolute monetary value (5.50). This is not required for TwoForOneCheapestFree offers.",
Order = 500)]
publicvirtualdecimal DiscountLegacy { get; set; }
[Display(
Name = "Extra Qualifiers",
Description = "Optional - used to narrow down the applicability of the promotion, e.g., to a particular membership product code. If a list, separate by commas. Include the code PM_CC or PM_DD to restrict the promotion to credit card or direct debit respectively.",
Order = 600)]
publicvirtualstring ExtraQualifiers { get; set; }
}
and then created a corresponding content item and made sure it satified all the conditions to be active.
I then created my processor:
public class LegacyEntryPromotionProcessor : EntryPromotionProcessorBase
{
protected override RewardDescription Evaluate(LegacyEntryPromotion promotionData, PromotionProcessorContext context)
{
throw new NotImplementedException();
}
protected overridebool CanBeFulfilled(LegacyEntryPromotion promotionData, PromotionProcessorContext context)
{
throw new NotImplementedException();
}
protectedoverridePromotionItems GetPromotionItems(LegacyEntryPromotion promotionData)
{
throw new NotImplementedException();
}
}
I then call the following at the appropriate point in the code.
var Rewards = GetPromotionEngine().Run((IOrderGroup)(EpiserverCommerceData.CartOld));
EpiserverCommerceData.CartOld.AcceptChanges();
At this point, I expected at least one of the functions defined in my LegacyEntryPromotionProcessor class to be called but
no joy - is there anything else that I need to do?
Thanks