Replies: 4 comments 3 replies
-
I guess at the moment this would be expected behaviour because ultimately the second code is valid (so no exception) but it doesn't apply (so it's unfulfilled because the first rule blocked it). Also bare in mind, rules are checked in the order of them within the back office, not the order in which they are applied to the order so you'll want to ensure your most dominant reward is higher up in the list. I appreciate the discounts system isn't that logical in some places. We have been trying to address some of it over time, but it might be in future we come up with a new approach. As it stands then, I'd suggest this falls under a feature request so I'll move it to a disucssion instead of an issue. But I appreciate the input. Another option could be to create a custom validation event handler for https://docs.umbraco.com/umbraco-commerce/key-concepts/events#validation-events |
Beta Was this translation helpful? Give feedback.
-
Thanks for the background info @mattbrailsford. I did wonder if it was less of a bug, and more "by design". It can definitely see how the complexities around it can increase rapidly. Another question I have then is, what is the purpose of the
I appreciate i'm not necessarily providing any solutions here, and I know how complex it must be under the hood, but figured it might be useful to provide some other use cases to help myself and others get a firmer understanding of it. It may help to work out future functionality too. |
Beta Was this translation helpful? Give feedback.
-
Interesting, I see how throwing and error wouldn't work. At the moment I've updated my workaround so that it added an additional check after the first Maybe the |
Beta Was this translation helpful? Give feedback.
-
I'm not sure if that would work in the context of error handling during a request though right? For example, I have an API endpoint for applying the discount code which should return a success or error message. If I used the |
Beta Was this translation helpful? Give feedback.
-
Which Umbraco Commerce version are you using? (Please write the exact version, example: 10.1.0)
13.2.1
Bug summary
When using the
Block further discounts from being applied
orBlock discount if discounts already apply
, theRedeem(<code>)
method on an order behaves in a confusing way.Specifics
I have two discount codes,
TEST10
andTEST20
, which apply and 10% and 20% discount on the order total. For both of these discounts, I have tried adding both block rules, individually and together.Based on how the
Redeem
method works for non-existed discount codes, e.g. it throws a validation exception error sayingNo discount or gift card found with the code '<code>'
, I would expect it to behave in the same manner based on those built in block rules.Instead, it still applied the additional discount code, but marks the
IsFulfilled
value asfalse
. This makes it a little cumbersome when providing feedback to the UI.For not I am adding an additional check, after the
SaveOrder
method is called on the order, and before theuow.Complete
is called to check is the discount was applied. Here's and example of the code i'm currently using as a workaround.Based on how it throws an exception for non-existent errors, it feels like it should also throw the same sort of error, providing a clearer error message based on the type of block rule and discount / gift card code. At the moment, I can't find a clear way to get a specific type of error based on those build in block rules.
I'm not 100% sure if this is a bug, or expected behaviour.
On a related note, In the Umbraco.Commerce.Checkout package but default, if you follow the steps to reproduce, it will actually show both discount codes, even through only one is actually active. This is more to highlight the issue.
Steps to reproduce
This assumes Umbraco Commerce is already installed with configured products, and has a working checkout flow.
TEST10
discount code, that talks 10% off the order total price and enable theBlock discount if discounts already apply
ruleTEST20
discount code, that talks 20% off the order total price and enable theBlock discount if discounts already apply
rule.TEST10
discount code to the cartTEST20
discount code to the cart. There will be no clear indication that this hasn't been applied based on the block rules, other than checking theIsFulfilled
value after saving the order.Expected result / actual result
If trying to apply a second discount code, when
Block discount if discounts already apply
, and/orBlock further discounts from being applied
, theRedeem(<code>)
method should return an exception with a relevant error message.Dependencies
Umbraco.Commerce.Checkout, but this isn't necessarily required.
Beta Was this translation helpful? Give feedback.
All reactions