Recommend you look at using Related Entries and have logic in your Add to cart method to add the associated free product to the cart. You can then use the built-in item promotion to run the discount for the free product.
Alternatively, you could use packages to combine the 2 products into a single sku?
https://support.optimizely.com/hc/en-us/articles/4413192106765-Packages-and-bundles
I belive you can do that. You can extend EntryPromotion with the custom integration. You can put the free Item as Reward. Which should be added to the cart once you add the product from current promotion.
This should look like this -
[ContentType(GUID = ".....", GroupName = "entrypromotion", Order = 20000,
DisplayName = "Spend for free Items")]
[ImageUrl("/EPiServer/Commerce/Images/SpendAmountGetGiftItems.png")]
public class SpendAmountGetGiftItems : EntryPromotion, IPurchaseAmount
{
[Display(Order = 10, Name = "Promotion Reward")]
[PromotionRegion("Reward")]
public virtual ContentArea RewardContainers { get; set; }
}
In the next step you can get specified gift items running under a promotion. So we should have an intercepter for this promotion, Which should look like this -
[ServiceConfiguration(Lifecycle = ServiceInstanceScope.Singleton)]
public class SpendAmountGetGiftItemsProcessor : EntryPromotionProcessorBase<SpendAmountGetGiftItems>
{
protected override PromotionItems GetPromotionItems(SpendAmountGetGiftItems promotionData)
{
return new PromotionItems(promotionData, new CatalogItemSelection(null, CatalogItemSelectionType.All, true),
new CatalogItemSelection(promotionData.RewardContainers.Items.GetItemsFromCatalog(),
CatalogItemSelectionType.Specific, false));
}
}
This is not tested and may need tweaks as well. But this should give you some ideas I belive.
For further reference, You can follow
https://docs.developers.optimizely.com/customized-commerce/v13.0.0-commerce-cloud/docs/custom-promotions
Hello all,
I need to build a promotion that works like this:
In edit promotion mode I have 2 sections:
Condition - here I place a product
Reward - here I place another product (to be added to cart with 0 price)
I was able to do a front-end part (which is a class inherited from OrderPromotion)
But I have hard time on creating a processor for this promotion...
Do anybody have experience/sample code for this sprecific type of promotion?
BTW, the free product should be added to the cart(if it's not already there) in the Evaluate method of the Promotion processor.
Appreciate any help on this!