# Order Rules (Admin)

Product order rules can be used to allow and block a user to purchase some products depending on some situations:

* Time: You can define some order rule to allow user of purchasing only in some specific time range
* Purchase Limit: You can define how much tokens the user can purchase

The permission to purchase is defined by some whitelist which can be created inside the ID service. That whitelists can be linked into each order rule and defines if some user can or not purchase some product.

Whitelists can specify users by email, wallet address or users who owns some token.

{% hint style="info" %}
One product can have more than one order rules, which means that you can create some complex blocking logics for your products:\
\
**Example: During the first week only priority users can purchase and after that, it's opened to the public.**
{% endhint %}

<details>

<summary>Order Rule Model (Example)</summary>

```json
{
    "id": "6368dfb5-f48c-48b1-be13-dd413548a558",
    "createdAt": "2022-10-17T21:47:12.505Z",
    "updatedAt": "2022-10-17T22:04:00.373Z",
    "companyId": "010e92ea-d3af-40d9-a19e-a263fdfe6e92",
    "productId": "010e92ea-d3af-40d9-a19e-a263fdfe6e12",
    "whitelistId": "010e92ea-d3af-40d9-a19e-a263fdfe6e94",
    "startAt": null,
    "endAt": null,
    "purchaseLimit": null
}
```

</details>

## Service Methods

### Creates some order rule inside a company product

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products/{productId}/order-rules" method="post" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Lists all orders rules from some company product

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products/{productId}/order-rules" method="get" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Gets one specific product order rule by id

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products/{productId}/order-rules/{orderRuleId}" method="get" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Updates some specific product order rule

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products/{productId}/order-rules/{orderRuleId}" method="patch" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}

### Deletes some specific product order rule

Rest API reference:

{% openapi src="<https://commerce.pixway.io/sdk-json>" path="/admin/companies/{companyId}/products/{productId}/order-rules/{orderRuleId}" method="delete" %}
<https://commerce.pixway.io/sdk-json>
{% endopenapi %}


---

# 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://w3block.gitbook.io/w3block-eng/dev-docs/api/commerce-api-services/company-administration/products-admin/order-rules-admin.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.
