Extending an existing promotion in Commerce v10.8.0

Vote:
 

Hello

I have extended the SpendAmountGetItemDiscount promotion data, with the following property:

    [ContentType(DisplayName = "Custom Spend for Discounted Selection", GUID = "32bba45a-080f-4261-8883-d8475f64603e")]
    public class CustomSpendForDiscountedSelectionPromotionData : SpendAmountGetItemDiscount
    {        
        [EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor))]
        [Display(Name = "Exclude these brands from discount...", Order = 10)]
        [PromotionRegion(PromotionRegionName.Discount)]
        public virtual IList Brands { get; set; }
    }

In the processor I wish to exclude the products that is associated with brands added in my custom property. Next I have created this processor:

    public class CustomSpendForDiscountedSelectionPromotionProcessor : GetItemDiscountProcessorBase
    {
        private readonly CollectionTargetEvaluator _targetEvaluator;
        private readonly LocalizationService _localizationService;
        private readonly FulfillmentEvaluator _fulfillmentEvaluator;
        private readonly Func _targetGetter;
        private readonly Func _discountGetter;

        public CustomSpendForDiscountedSelectionPromotionProcessor(CollectionTargetEvaluator targetEvaluator, LocalizationService localizationService, Func targetGetter, Func discountGetter, FulfillmentEvaluator fulfillmentEvaluator) : base(targetEvaluator, localizationService, targetGetter, discountGetter)
        {
            _targetEvaluator = targetEvaluator;
            _localizationService = localizationService;
            _targetGetter = targetGetter;
            _discountGetter = discountGetter;
            _fulfillmentEvaluator = fulfillmentEvaluator;
        }

        protected override PromotionItems GetPromotionItems(CustomSpendForDiscountedSelectionPromotionData promotionData)
        {
            throw new NotImplementedException();
        }

        protected override FulfillmentStatus GetFulfillmentStatus(CustomSpendForDiscountedSelectionPromotionData promotionData,
            PromotionProcessorContext context)
        {
            throw new NotImplementedException();
        }
    }

Using these two overrides is there any way to apply the logic stated above? 

After having tried a bunch of stuff I'm fearing I might have to inherit from EntryPromotionProcessorBase and write Evaluate from scratch, which seems overkill only to exclude some products from the discount...

Any ideas? Thanks in advance.

- Regards, Benjamin

#195822
Aug 08, 2018 16:28
Vote:
 

I've been down the same path and I came to the conclusion it wasn't possible unless writing your own evaluate. The thing you can do is if the brand exists in your cart, this promotion will not apply to any of the items in the cart. However, you can't have it not work for just 1 of the line items...

#195823
Aug 08, 2018 17:02
Vote:
 

There are ways of adding custom logic to always exclude an item from evaluation of promotion if it belongs to a brand, but I reckon that's not what you're after.

#195824
Aug 08, 2018 17:06
Vote:
 

I think Yoel requested this feature a while back and it is in our backlog, but it will not happen any time soon. Unless I can find some time working on it next hackday and find a reasonable solution for it.

But that would mean latest version :)

#195830
Aug 08, 2018 22:13
Vote:
 

Thanks for the answers guys! I'm going to inherit from EntryPromotionProcessorBase and write Evaluate from scratch. There seems to be some evaluators (TargetEvaluator, FulfillmentEvaluator) that can handle the baseline logic for me. I'll utilize those.

#195840
Aug 09, 2018 8:21
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.