Why Restrict Product Purchases With a Code?
Not every product should be available to everyone. There are legitimate business reasons to restrict who can buy certain items in your WooCommerce store:
- Exclusive product launches — only customers who received an invitation code can purchase early access products
- B2B wholesale gating — only approved resellers with a distributor code can order wholesale quantities
- Event-linked products — merchandise or add-ons available only to ticket holders
- Warranty replacements — customers need to enter their original product serial to order a replacement part
- Loyalty rewards — give your best customers a code that unlocks access to a limited product
- Controlled distribution — ensure products are only sold through authorized channels
WooCommerce does not have this feature built in. Coupon codes give discounts, but they do not prevent purchase entirely. Password-protected products hide the product but feel clunky. What you need is a code gate at checkout that blocks the transaction unless a valid serial is provided.
How Purchase Restriction Works
With the Serial Codes Generator and Validator plugin, you can assign a code list to a WooCommerce product as a “purchase restriction.” When this is active:
- The product appears normally in your shop — customers can see it, read the description, and add it to cart
- At checkout (or in the cart), an input field appears asking for the purchase allowance code
- If the customer enters a valid, unused code from the assigned list, the order proceeds normally
- If the code is invalid, already used, or missing, the checkout is blocked with a clear error message
The product remains visible in your catalog. This is intentional — you want potential customers to see it, understand its value, and be motivated to obtain a purchase code. Hiding the product entirely removes it from discovery.
Setting Up Purchase Restrictions
Step 1: Create the Code List
Create a dedicated code list for purchase restriction codes. These are separate from product serial numbers — they control access to the purchase, not the product itself.
For example, if you are launching an exclusive product for newsletter subscribers, generate 500 codes and email one to each subscriber.
Step 2: Enable the Feature in Plugin Settings
In the plugin settings, activate the purchase restriction feature. Configure:
- Cart info text — the message shown next to restricted products (e.g., “This product can only be purchased with a code”)
- Input placeholder — the text inside the code input field (e.g., “Enter purchase allowance code”)
- One-time usage — whether each code can only be used for one purchase
Step 3: Assign the Restriction to a Product
Open the WooCommerce product editor. In the plugin section, select the code list that should be used as the purchase restriction. Save the product.
From this point on, any customer trying to buy this product will need to enter a valid code from that list.
One-Time vs. Multi-Use Restriction Codes
You have three options for how restriction codes are consumed:
- Use the global one-time-usage setting — follows whatever you configured for the code list
- Mark immediately as used — each code works for exactly one purchase, then it is consumed
- Unlimited usage — the same code can be used by multiple customers (useful for B2B scenarios where one distributor code unlocks purchases for an entire organization)
For exclusive launches, one-time usage is almost always the right choice. For B2B gating, unlimited usage per code makes more sense.
What Happens When Orders Are Refunded
If a customer receives a refund for a restricted product, the plugin can optionally release the restriction code — making it available for reuse. This is controlled by a setting: “Clear the code if the order was deleted or a refund triggered.”
Enable this for scenarios where the code represents a right-to-purchase that should be preserved (e.g., a VIP access code that should still work after a cancelled order). Disable it if the code should be permanently consumed regardless of order outcome.
Combining Restriction Codes With Auto-Assigned Serials
A powerful pattern: use one code list as the purchase gate, and a different code list as the serial number assigned after purchase. The customer enters their invitation code to unlock the purchase, and upon completion, receives a unique product serial for verification or license activation.
This gives you two layers of control:
- The restriction code controls who can buy
- The serial code identifies what they bought
Real-World Scenarios
Exclusive Product Launch
You are launching a limited-edition product. Generate 200 purchase codes and email them to your VIP customer list. Only these 200 customers can buy the product. Everyone else sees the product page but cannot complete checkout — creating demand for your next exclusive launch.
B2B Wholesale Store
Your WooCommerce store serves both retail and wholesale customers. Retail products are open to everyone. Wholesale products require a distributor code. Each approved distributor receives a multi-use code that their entire team can use to place orders.
Warranty Replacement Parts
Customers needing replacement parts must enter their original product serial number. This verifies they own the product and prevents unauthorized purchases of parts that should only go to existing customers.
Conference Merchandise
You are running an event and selling branded merchandise through WooCommerce. Only conference attendees should be able to buy it. Generate one purchase code per ticket and include it in the ticket confirmation email. Attendees can buy merchandise; non-attendees cannot.
Customer Experience Considerations
A few tips to ensure the restriction does not frustrate legitimate customers:
- Explain clearly on the product page why a code is needed and how to get one
- Use descriptive placeholder text — “Enter your VIP access code” is better than “Enter code”
- Provide a fallback — include a support email or contact form for customers who should have a code but do not
- Make the code input visible — do not bury it in fine print at checkout
Getting Started
Purchase restriction is a feature that no standard WooCommerce plugin provides out of the box. It fills a real gap for businesses that need controlled distribution without hiding products or building custom checkout logic.
The purchase restriction feature is available in the free Serial Codes Generator and Validator plugin. Install it and test the workflow on a staging product before going live.