In the era of online courses, subscriptions, custom-made products and product personalization, it may happen a scenario where a user can only purchase a product once in their lifetime.
In this short tutorial, we will see how this is done.Clearly, the user must be logged in in order for the code to trigger, so this applies to stores that require checkout login in order to proceed with the order.
Enjoy!
User “Tutor Aspire” is currently logged in and in the past he purchased this same product. Result: the add to cart button is not showing thanks to the snippet below.
PHP Snippet: One Product Purchase in a Lifetime @ WooCommerce Single Product / Cart / Checkout
it would be nice to add a notice to tell the user why the Add to Cart is not showing. The snippet above ONLY hides the add to cart
in case the already purchased product is in the Cart, and user logs in from there, item will be removed from the Cart and an error message will be displayed
same applies to the Checkout page, in case the user logs in from there