You could create a discount code discount, then create a new rule which checks the database for orders with the same customer reference that are using this discount. If the number exceeds the allowed amount then fail the rule, thus the discount won’t apply.
How to set the path for labelView? For example, I created a folder named Rules and a view file under it. I've tried with LabelView = "~/rules/example.html" but it doesn't work, it can't find the file specified Request error: The URL returned a 404 (not found).
How to get the current discount code in the OrderDiscountRuleProvider? The problem occurs when more than one discount code is applied. Currently I can only get all the discount codes from the order. I don't know which code should be checked with my custom discount rule. Should I check all the codes where isFulfilled is false?
1) In chrome dev tools can you see what URL is being requested? And, is that URL where your label view is located? It might be that you need to exclude the ~
2) Hmm, good question. It looks like we do pass a DiscountRuleContext but this doesn't currently hold a reference to the discount which I think this probably could / should. I've reported this on our issue tracker here https://github.com/vendrhub/vendr/issues/189 and have already created a patch for it that will be in version 1.3.1, if you want to test this prior to release, you can find a beta build on our CI NuGet feed at https://nuget.outfield.digital/unstable/vendr/v3/index.json, you'll want to try the 1.3.1-beta0009 build (all beta builds will be upgradable to final release builds)
Limit Discount Usage for Each Member
Hi,
I need to limit the discount usage so that each member can only apply the discount once. Is it possible to do this?
Thanks
Hi Nalysa
Not out of the box but you could create your own discount rule https://vendr.net/docs/core/1-3-0/key-concepts/discount-rules-and-rewards/
You could create a discount code discount, then create a new rule which checks the database for orders with the same customer reference that are using this discount. If the number exceeds the allowed amount then fail the rule, thus the discount won’t apply.
Hope this helps
Matt
Hi Matt, thanks for your help
Now I face some issues:
How to set the path for labelView? For example, I created a folder named Rules and a view file under it. I've tried with
LabelView = "~/rules/example.html"
but it doesn't work, it can't find the file specifiedRequest error: The URL returned a 404 (not found)
.How to get the current discount code in the
OrderDiscountRuleProvider
? The problem occurs when more than one discount code is applied. Currently I can only get all the discount codes from the order. I don't know which code should be checked with my custom discount rule. Should I check all the codes whereisFulfilled
is false?Hi Nalsya,
1) In chrome dev tools can you see what URL is being requested? And, is that URL where your label view is located? It might be that you need to exclude the
~
2) Hmm, good question. It looks like we do pass a
DiscountRuleContext
but this doesn't currently hold a reference to the discount which I think this probably could / should. I've reported this on our issue tracker here https://github.com/vendrhub/vendr/issues/189 and have already created a patch for it that will be in version 1.3.1, if you want to test this prior to release, you can find a beta build on our CI NuGet feed at https://nuget.outfield.digital/unstable/vendr/v3/index.json, you'll want to try the 1.3.1-beta0009 build (all beta builds will be upgradable to final release builds)Matt
is working on a reply...