WooCommerce Tutorial: Allow users only to purchase items once

Ever had a store where you don’t want to let your users purchase the same item twice?

There are a few use-cases where this might be true, but whatever the root cause, if you have registered users on your WordPress and WooCommerce store, and it would be helpful for you to prevent customers from re-buying something they already purchased before, the snippet below might help you to get this done.

Please note you may want to add extra to this, like locking it to a product category or tag or specific product IDs. All of these features would be custom code which you’d want to ask a developer about (contact us or post a task onto Codeable!).

But if you just want to not allow any registered user from purchasing the same item twice, the below added to a functions.php file, or custom plugin, will get this done for you!

How to allow users only to purchase items once

This snippet should be added into your functions.php file, or even better, a plugin which contains such snippets, or perhaps a custom plugin.

Leave a comment if this helped you!

4 thoughts on “WooCommerce Tutorial: Allow users only to purchase items once”

  1. Works great, if I wanted to replace the “Buy Now” button instead of having an error message, could I do that inside this code as well?

    • Hi – what you’re describing could be achieved, but it would need to happen “before” the button is clicked (this code hooks into the “add to cart validation” filter `woocommerce_add_to_cart_validation`) therefore, you’d need to do this “some other way” – probably when the product page is loaded.

      It should be possible. Probably it would be worth posting this as a small task for a developer to complete – try Codeable (a dedicated WordPress freelancer service with only expert devs on it) – we have a form where you can send them a task here:


      (note we will be marked as referrers, and we are “affiliated” i.e. this is a partner form, but the benefit – for our referrals – is this means I can share the task link to the great Woo devs on there I know to get someone with more availability than we to take a look!).


Leave a comment

No links of any kind allowed in comments - if you add any links, your comment will automatically be deleted.