Prevent Customers from buying product more than once

This entry is part 6 of 6 in the series WooCommerce Development

In some scenarios you may want to prevent your customers from buying one product multiple times. A services selling or e-learning site may want to do this. Because buying a course more than once, does not make a sense.

You can prevent customers from buying woocomerce product more than once. The code will display message ‘Enrolled’ in place of ‘Add To Cart’ button, if the logged in customers have already purchased the product. You can customize this message according to your needs.

Create a new php file add-to-cart.php in directory ‘woocommerce/loop’  you will have to create these folders in your themes root like below

woocommerce/loop/add-to-cart.php

 

But, the problem is not yet fixed. With the above code you can only display them a message instead of ‘Add To Cart’ button, if they click on the product and click on ‘Add To Cart’ button on single product page they can still buy it. To prevent them from buying the product, paste the below code to you themes functions.php file

You can display a nice message to your customers if they click on ‘Add To Cart’ button, even if they already purchased it.

Please let me know in comments if you face any issues.

 

Series Navigation<< Remove Grouped Product Price in WooCommerce