# Create a Cart Price Rule in Magento 2.x

An automation in Personal Discount needs a Cart Price Rule to which it will be adding coupon codes.

You can prepare a Cart Price Rule in your Magento admin panel.

Navigate to Marketing > Cart Price Rules and click on Add New Rule.

![Magento Cart Price Rules](/files/-L_kg_VvCjMyFTxEQDVm)

Cart Price Rules in Magento provide a variety of options. The essential ones are:

**Rule Name** - will appear on the select list in Personal Discount

![](/files/-L_kpf-wBAPM6rnTj_AH)

**Active** - yes

**Websites** - select all, unless you want to limit the coupon to specific website

**Customer Groups** - select all, unless you want to limit the coupon to a specific customer group

![](/files/-L_kq4W4jYVcT4XkH0C-)

&#x20;**Coupon** - Specific Coupon

&#x20;**Use Auto Generation** - checked, this is key for Personal Discount to work properly

![](/files/-L_kqcTefeavzjT14vMo)

**Uses per Coupon** - how many times a customer can use a coupon code

**Apply** - discount type, possible choices are:

* Percent of product price discount
* Fixed amount discount&#x20;
* Fixed amount discount for whole cart
* Buy X get Y

**Discount Amount**

![](/files/-L_ksS1BEdW29bvrVi0J)

Save the Price Rule and switch to Personal Discount automation settings. Now, you can select the newly created "Welcome 10% off" as a Cart price rule for your automation.

![](/files/-L_kt-HlQQH4rb5YJ6ki)

The automation will start adding coupon codes to the selected Price Rule. You can find the generated coupons in the Manage Coupon Codes section of your Cart Price Rule:

![](/files/-L_ku4gUJWH31k3C4-dg)

{% hint style="info" %}
You won't see expiration date in the coupon codes table, because it's a limitation of Magento API. However, Personal Discount keeps track of when the coupon should expire and removes them at a right time.
{% endhint %}


---

# 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://docs.personaldiscount.io/woocommerce-and-magento/create-a-cart-price-rule-in-magento2.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.
