WooCommerce: Prevent Multiple Purchases of a Product

WooCommerce: Allow Product Purchase Only Once per User

If you’re selling something that should only be purchased once—like subscriptions, memberships, or licenses—this tutorial shows you how to stop repeat purchases per customer.

Why Enforce Single-Time Purchase?

For certain products, allowing repeat purchases can create confusion or technical issues. Blocking additional purchases ensures customers don’t buy the same item again by mistake.

How to Set It Up

We’ll use a simple WooCommerce filter that stops users from buying an already purchased product, based on their login session.

Step 1: Paste Custom PHP

Add the following to your functions.php or plugin:

function restrict_single_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', 'restrict_single_purchase', 10, 3);
How It Works
  • Only logged-in customers are checked
  • If a product was purchased before, it’s marked as not purchasable
Step 2: Test It Out

Log in as a customer who already bought a product, then revisit the product page. The “Add to Cart” button will be disabled.

Limitations

This won’t stop guest users or logged-in users with new accounts. For complete restriction control, consider using advanced plugins or a custom solution tailored to your use case.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.