# Restricting a product so that it can only be purchased by new customers

{% hint style="info" %}
**Note:** This functionality requires the customer to have or create an account for access. There's more on that below.
{% endhint %}

You'll start by locking your product. You can search for it by name in the Locksmith search bar to create that lock.

{% content-ref url="/pages/M9JRoxsNMqxR7taTbDTe" %}
[Creating locks](/basics/creating-locks.md)
{% endcontent-ref %}

Next, you'll need to set a key with two different conditions:

* **Permit if the customer is signed in, and**
* **permit&#x20;*****unless*****&#x20;the customer has purchased "\*"**

For Locksmith to determine whether a customer has made a previous purchase, you must require customers be signed in to access this product. This is done by adding an "**is signed in**" key condition to your key.

The second condition checks the customer's order history to see if they've made any purchases at all. For this, combine the "**has purchased...**" key condition with the "is signed in" key condition. Adding an asterisk to the "Look for products matching..." field tells Locksmith to check for any purchase in the customers history. Finally, ensure you enable the "invert" option on this condition to block customers who have made a purchase before.

{% content-ref url="/pages/ZcLkHf2n32p0GJzwXZME" %}
[Combining key conditions](/keys/more/combining-key-conditions.md)
{% endcontent-ref %}

Here's what that should look like:\ <br>

<figure><img src="/files/jX2DjNGW0evmvE41OMAP" alt=""><figcaption></figcaption></figure>

When the full key is created, your key should look like this:

<figure><img src="/files/u3MG1zHsFA3xX62XOnPg" alt=""><figcaption></figcaption></figure>

When this is all set, the customer will be prompted to log in when they try to access the product. If they already have a purchase in their history, they'll see the Access Denied message.

You can edit the access messages on the Locksimth app's settings page, or editi the access messages for specific locks on the lock's settings page. Our guide on edditing access messages is linked below.

{% content-ref url="/pages/YN4tss8Ren6LqyAQ78LD" %}
[Customizing messages](/tutorials/more/customizing-messages.md)
{% endcontent-ref %}

## Related articles:

{% content-ref url="/pages/A0WwFznqJob71sDH7rUK" %}
["Has purchased..." key](/keys/more/has-purchased.md)
{% endcontent-ref %}

{% content-ref url="/pages/Rtavrz1uam6HlWPicwww" %}
[Selling digital content on Shopify](/tutorials/selling-digital-content-on-shopify.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.locksmith.guide/tutorials/more/restricting-a-product-so-that-it-can-only-be-purchased-by-new-customers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
