November Happy Hour will be moved to Thursday December 5th.

Need Assistance on Promotion

Vote:
 

Hi,

If a customer buys a set of items, we would give one item(which is not in that set) free. There is no default Epi promotion to achieve this. Is there any way to customize?

We tried,

"Buy Products for Discount from Other Selection
Buy at least X items from catalog entries and get related catalog entries at a discount. " promotion with 100%.

Thanks in Advance.

#205070
Jun 27, 2019 16:13
Vote:
 

We ended up writing a custom promotion for that, following the guide:

https://world.episerver.com/documentation/developer-guides/commerce/marketing/custom-promotions/

Look into the implementation for the default "Spend for free items" promotion and any promotion that has a selection for inspiration.

#205071
Jun 27, 2019 16:42
Vote:
 

Thanks, Erik Norberg,

I implemented a custom promotion. But how can I pass "Limit number of discounted items" value to Promotion Engine? and how to pass dynamic values to "Limit number of discounted items"?

#205104
Jun 28, 2019 12:55
Vote:
 

I don't follow you, what value is that?

Can you share the code of your implementation?

#205118
Jun 28, 2019 15:24
Vote:
 

Thanks for your reply.

I use the below code.

protected override RewardDescription Evaluate(EntryPromotion promotionData, PromotionProcessorContext context)
        {
            var lineItems = GetLineItems(context.OrderForm);
           
            var condition = promotionData.Condition;
            int requiredQuantity = condition.RequiredQuantity;
           
            var applicableCodes = targetEvaluator.GetApplicableCodes(lineItems, condition.Targets, condition.MatchRecursive);

           
            //// filter the lineitems based on the required quantity(line item qty should be equal or greater than required quantity).
            var filteredLineItems = GetFilteredLineItems(lineItems, requiredQuantity, condition.MixMatch);

            //// filter the applicable codes based on the filtered lineitems.
            var filteredApplicableCodes = GetFilteredApplicableCodes(applicableCodes, filteredLineItems);
           

            var fulfillmentStatus = fulfillmentEvaluator.GetStatusForBuyQuantityPromotion(
            filteredApplicableCodes,
            filteredLineItems,
            requiredQuantity,
            minRequiredQuantity
            );           

            return RewardDescription.CreatePercentageReward(
                fulfillmentStatus,
                GetRedemptions(filteredApplicableCodes, promotionData, context, lineItems),
                promotionData,
                promotionData.Percentage,
                fulfillmentStatus.GetRewardDescriptionText(localizationService));
        }

I need   

" Buy Products for Discount from Other Selection
Buy at least X items from catalog entries and get related catalog entries at a discount." promotion.

If user buy A,B,C (3) products,we should apply 10% discount for Product D.If I use this default its working fine.But How can I pass "(Limit number of discounted items)MaxQty" in Evaluate method.Is there any possiblity?

kindly help.

#205120
Jun 28, 2019 15:55
Vote:
 

Is this a new promotion and no longer the give away from your original post?

For give aways your processor should inherit form the GetFreeItemsProcessorBase

public class YourCustomPromotionProcessor : GetFreeItemsProcessorBase<YourCustomPromotionData>

What does your PromotionData look like?

#205124
Jun 28, 2019 16:12
Vote:
 

Than you.

I used EntryPromotionProcessorBase.

MyEntryPromotionProcessor : EntryPromotionProcessorBase<MyEntryPromotion>

Can you explain me the Evaluate() method for  GetFreeItemsProcessorBase?.How can I achieve this?

#205130
Jun 28, 2019 17:19
Vote:
 

Decompiling the source code for GetFreeItemsProcessorBase gives you:

	protected override RewardDescription Evaluate(TEntryPromotion promotionData, PromotionProcessorContext context)
	{
		PurchaseQuantity purchaseQuantity = _conditionGetter(promotionData);
		IList<string> applicableCodes;
		FulfillmentStatus fulfillmentStatus = purchaseQuantity.GetFulfillmentStatus(context.OrderForm, _targetEvaluator, _fulfillmentEvaluator, out applicableCodes);
		if (!fulfillmentStatus.HasFlag(FulfillmentStatus.Fulfilled))
		{
			return NotFulfilledRewardDescription(promotionData, context, fulfillmentStatus);
		}
		context.AddConditionalItems(promotionData.get_ContentLink(), applicableCodes, purchaseQuantity.RequiredQuantity);
		IEnumerable<RedemptionDescription> redemptions = GetRedemptions(promotionData, context, applicableCodes);
		return RewardDescription.CreateFreeItemReward(fulfillmentStatus, redemptions, promotionData, fulfillmentStatus.GetRewardDescriptionText(_localizationService));
	}

Of course you have to replace the PurchaseQuantity condition with your own one to support your use cases.

#205175
Jul 01, 2019 15:04
Vote:
 

Thanks..Its working fine.

But,For example if I add 5 products to cart and i give purchaseQuantity.RequiredQuantity as 1,discount will  apply for only one  product.But it applied to 5 products.

#205231
Edited, Jul 02, 2019 12:57
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.