Learn in this tutorial how to prevent a customer from buying more than once an Easy Digital Downloads (EDD) product through code.
In a previous tutorial you learned how to avoid duplicates in Easy Digital Downloads cart.
But that only applies when the users try to add more than once the product in the checkout at the same time. If they come back another day you won’t be able to prevent them from buying the product again.
And you may ask yourself, why would I want to prevent them from buying a product more than once?
Well, for example, if you have a subscription website (with Recurring Payments), where you want to prevent someone who has already created a subscription from creating a new one because they don’t remember that they did it some time ago.
And I’m sure there may be other examples. 😉
So let’s see how you can achieve this:
Snippet to prevent a customer from buying more than once a product from Easy Digital Downloads
Add the following code at the end of functions.php or in your functionality plugin:
This code checks if the user has already purchased the product and if so, displays an error message.
Obviously, you can modify the message to your liking.
Do you want to prevent a customer from buying more than once a product from Easy Digital Downloads? Now you know how to do it easily with code.
Any questions? I read you in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉