Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rody van Sambeek 67 posts 202 karma points
    5 days ago
    Rody van Sambeek
    0

    Limit usage of discounts codes on Customer Email...

    We have a client which requires the following scenario:

    • 30 days after Product A is ordered and Product A is not yet reordered by the customer, an automated MailChimp e-mail is sent which should contain a discount code (say 10% discount).
    • This discount may only be used once.

    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?

  • Matt Brailsford 2848 posts 14796 karma points MVP 7x c-trib
    5 days ago
    Matt Brailsford
    100

    Hey Rody,

    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

    Matt

  • Rody van Sambeek 67 posts 202 karma points
    5 days ago
    Rody van Sambeek
    0

    Hi Matt,

    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?

    Thanks! Rody

  • Matt Brailsford 2848 posts 14796 karma points MVP 7x c-trib
    5 days ago
    Matt Brailsford
    0

    Hi Rody,

    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;
    

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft