November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Looks like there is a validator for PurchaseAmount. I tried to put a validator for the promotion, but it didn't override the PurchaseAmount's validator.
My current workaround is not using PurchaseAmount, but using
public virtual IList<Money> Amount { get; set; }
It renders to the wonderful currency-amount-list I thought I'd lose :) However there is one drawback: I cannot use
PuchaseAmount.CanBeFulfilled(context.OrderGroup.Currency)
It is a pretty minor drawback though, that check can easily be done without it.
You could workaround by creating new extension like this:
public void CanBeFulfilled(this IList<Money> amount, Currency orderCurrency) { return amount != null && amounts.Any(a => a.Amount > 0 && a.Currency == orderCurrency); }
Regards,
/Son Do
True, but then this would be overridden for all promotions using PurchaseAmount, wouldn't it? I only want my custom promotion type to allow empty values in PurchaseAmount.
Regards,
Joel Yourstone
Hi Joel,
It won't override PurchaseAmount.CanBeFulfilled, you could verify this :)
CanBeFulfilled is just a shortcut to check if the order is not qualified for the promotions. So if you are using PurchaseAmount, it checks if the currency of the order can satisfy the conditions in PurchaseAmount.
The reason you can't save the promotions with PurchaseAmount which has amount = 0 was because there is a validator (PurchaseAmountValidator) validates that. This validator however can't be disabled. Simply speaking, PurchaseAmount = IList<Money> + some validation. So in your requirements, switching to IList<Money> is the way to go.
Yeah I can easily do that check on my own, in the promotion processor. Thanks Son and Quan!
Hi all!
I'm working on a custom promotion and the condition consists of
I would like the amount to be optional. The idea behind the promotion is "Buy from [specific category?] for at least [amount or optional = 0]...", but it doesn't look like the PurchaseAmount can be made optional, I can't save the promotion if is either not set or 0.
I could always just make a decimal/int for it, but then I lose the wonderful currency-amount-list that PurchaseAmount gives me.
Is it possible to somehow make it optional?
Regards,
Joel Yourstone