Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
We have a client which requires the following scenario:
This client wants to create 1 discount code, i.e.: "WELCOMEBACK" which is mailed to the customer and wants to limit the usage of that code to the customer e-mail. So that only one order can be made with that discount code per customer e-mail.
I don't think this is possible at the moment right?
We proposed a different solution, we generate a new Discount Code on the moment the customer buys Product A and send this to MailChimp as a new merge-field. This way the discount code is genuinly unique for that customer.
However this solution can generate a lot of unique discount codes in the back-end. Is this a problem?
Or is there another / better and cleaner solution to this problem?
It's possible, just not out of the box. Vendr discount rules and rewards are fully pluggable so you can define your own rules / rewards. So you could create a "Distinct Email" rule that checks the order for the customer email address and if one is present, do a DB query to see if there are any finalized orders using that email address. If there are not, then the rule can pass successfully.
You can find out more about custom rules / rewards in the documentation at https://vendr.net/docs/core/1-3-0/key-concepts/discount-rules-and-rewards/#discount-rewards
With a custom rule, you should be able to achieve the exact requirement the custom has asked for.
Hope this helps
Thanks again for this great idea. Indeed I could write a custom rule provider to add to the discount rule.
For searching the order history to check if there are earlier orders with applied discount rule, would you recommend using the OrderService.SearchOrders method? Can I filter there on a customer's email address?
I think it might be faster and less intensive to run a direct SQL statement specific to your needs.
var exists = database.ExecuteScalar<int>($"SELECT COUNT(1) FROM vendrOrder WHERE finalizedDate IS NOT NULL AND customerEmail = @0 AND storeId = @1", email, storeId) > 0;
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted