> For the complete documentation index, see [llms.txt](https://docs.samita.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.samita.io/b2b-lock-password-protect/access-rules/order-quantity.md).

# Order quantity

Match customers whose total order count meets a minimum — good for loyalty and repeat-buyer perks.

**Order quantity** matches a customer based on how many orders they've placed with your store in total, rather than what they bought. It's a good fit for loyalty or repeat-buyer perks — for example, unlocking a discount code or an exclusive product only for customers who've ordered from you a certain number of times before.

Like most access rules (aside from the action-based ones such as Passcode, Secret link, Subscribe, and Confirmation prompt), Order quantity can be set to match **If** the customer meets the order-count threshold, or **Unless** they don't — inverting it to match customers below the threshold instead. See [Combining rules](/b2b-lock-password-protect/access-rules/combining-rules.md).

{% hint style="info" %}
This rule reads order history from a signed-in Shopify customer account. With **If**, a guest cannot meet the order threshold; with **Unless**, a guest has no matching order history and therefore satisfies the inverted condition.
{% endhint %}

## Add the rule

1. Open **Locks** and create a new lock, or open an existing one to edit it.
2. Choose the content you want to protect. See [Access rules overview](/b2b-lock-password-protect/access-rules/overview.md) for how rules fit into a lock.
3. Click the **Unlock rules** tab, then in the **Condition type** dropdown, select **Order quantity**.

<figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-5920b71cbe78ca0e9d897a314b4b2e098a1eb918%2Fscreenshot-access-rules-picker-order-quantity.png?alt=media" alt="The Unlock rules tab with Order quantity selected in the Condition type dropdown."><figcaption><p>Select Order quantity from the Condition type dropdown on the Unlock rules tab.</p></figcaption></figure>

4. Set the **Order threshold** — the minimum number of orders the customer must have placed for the rule to match. The default is 1 order.
5. **Ignore cancelled orders** is on by default, so cancelled orders don't count. Untick it if you want them included.

<figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-de7cc05933819c6885d5fb35515e85dd8435e45d%2Fscreenshot-access-rules-order-quantity-config.png?alt=media" alt="The Order quantity rule settings, showing the order threshold field and the Ignore cancelled orders checkbox."><figcaption><p>Set the minimum number of orders a customer must have placed, and choose whether cancelled orders count.</p></figcaption></figure>

6. Choose **If** or **Unless**.
7. Click **Save**.

{% hint style="warning" %}
This rule counts up to the customer's **50 most recent orders placed within the last 60 days**. Orders older than 60 days are not included. If the customer placed more than 50 orders during that period, only the newest 50 are counted.
{% endhint %}

## Example: Unlock rewards after three orders

Suppose customers should be able to open a rewards page after placing at least three non-cancelled orders.

1. Select the **Repeat-customer rewards** page as the content to protect.

<figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-e1ff05e45700f2b76a79d6da852d5a3c566d642d%2Fscreenshot-example-order-quantity-content.png?alt=media" alt="The Lock setup tab with Specific Page as the content type and the Repeat-customer rewards page listed under Restricted pages."><figcaption><p>Pick the page that repeat buyers should unlock.</p></figcaption></figure>

2. On the **Unlock rules** tab, set **Condition type** to **Order quantity** and leave **Rule logic** on **If**.
3. Set **Order threshold** to **3**. Leave **Ignore cancelled orders** ticked — it's on by default.

<figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-de184ce393b123d930e6c2e130b8e89e06f77015%2Fscreenshot-example-order-quantity-rule.png?alt=media" alt="The Order quantity condition with Rule logic If, Order threshold set to 3, and Ignore cancelled orders ticked."><figcaption><p>The condition heading reads: If the customer order quantity matches.</p></figcaption></figure>

4. Leave the rule's **Redirect URL** empty.
5. In **Messages**, set the **Access denied message** to:

> Sign in with an account that has placed at least 3 orders to unlock these rewards.

{% hint style="info" %}
Order quantity shows only the **Access denied message** — there's no Guest message field, because the rule isn't one of the five customer-identity rules. See [Access rules overview](/b2b-lock-password-protect/access-rules/overview.md#what-a-blocked-visitor-sees).
{% endhint %}

<figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-bd813383da22725c37c601810a4cf0b1a7bf5f5d%2Fscreenshot-example-order-quantity-message.png?alt=media" alt="The Messages card with a single Access denied message field set to the three-order wording, and the Preview panel rendering it."><figcaption><p>The Preview panel confirms the wording before you save.</p></figcaption></figure>

6. Click **Save**.

### Result on the storefront

A signed-in customer with at least three counted orders can open the rewards page. A guest or a customer with fewer than three counted orders sees the Access denied message above.

<figure><img src="https://27754559-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF4qMYopXntYz9YgUqZSo%2Fuploads%2Fgit-blob-3817ddaeb0e990f6df11f40b852b022357ad9d7c%2Fscreenshot-example-order-quantity-result.png?alt=media" alt="The Repeat-customer rewards page displaying the configured three-order requirement."><figcaption><p>A visitor without three qualifying orders sees the Access denied message from this example.</p></figcaption></figure>

## Related docs

* [Access rules overview](/b2b-lock-password-protect/access-rules/overview.md)
* [Combining rules](/b2b-lock-password-protect/access-rules/combining-rules.md)
* [Purchased items](/b2b-lock-password-protect/access-rules/purchased-items.md)
* [Customer tags](/b2b-lock-password-protect/access-rules/customer-tags.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.samita.io/b2b-lock-password-protect/access-rules/order-quantity.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
