Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More →
If you want to allow customers to buy a WooCommerce product only once, you can use custom PHP code to stop users from placing repeat orders for that product.
Why Limit to One Purchase?
This feature is useful for exclusive products like memberships, one-time downloads, or limited-time offers. It avoids confusion and duplicate purchases.
How to Block Repeat Purchases
You can use WooCommerce hooks and functions like wc_customer_bought_product and woocommerce_is_purchasable to prevent repeat buys.
Step 1: Add Code to functions.php
Insert this code in your theme’s functions.php file:
function custom_restrict_duplicate_product_purchase($purchasable, $product_id, $user_id) {
if (is_user_logged_in()) {
if (wc_customer_bought_product('', $user_id, $product_id)) {
$purchasable = false;
}
}
return $purchasable;
}
add_filter('woocommerce_is_purchasable', 'custom_restrict_duplicate_product_purchase', 10, 3);
Step 2: Test It
Log in as a user who already purchased the product. When viewing the same product again, the "Add to Cart" button will be disabled.
What This Does
Limitations
This won’t stop guest users or users with a new account. You’ll need additional validation or a plugin to handle those cases.
Advanced Control
Want to block repeat orders across accounts or for guest users? Use a plugin like "WooCommerce Purchase Restrictions" or create a more advanced custom rule. 
Search our archives or reach out to our team for solutions and expert advice.