Hello Magento Friends,

In this blog, we will learn How to Add a Custom Field to the Cart Price Rules Form in Magento 2.

Cart price rules are created by the admin to apply discounts on shopping cart items based on certain conditions. Magento allows adding customization to the cart price rule creation. When you want additional rule parameters or custom behavior of cart discounts, you need a custom field in the cart price rules.

Follow the below steps to add a custom field to the cart price rules form in Magento 2.

Steps to Add a Custom Field to the Cart Price Rules Form in Magento 2:

Step 1: Create the “db_schema.xml” file inside our extension at the following path.

app\code\Vendor\Extension\etc\db_schema.xml

Now add the code as follows

Step 2: Create the “sales_rule_form.xml” file inside our extension at the following path.

app\code\Vendor\Extension\view\adminhtml\ui_component\sales_rule_form.xml

Then add the following code

Output:

cart price rules custom field

Conclusion:

Hence, following the above steps you can customize the cart price rules form in Magento 2 by adding a custom field. In case you face any difficulty, share it with me through the comment section and I will be quick to provide you with the solution. Moreover, share the solution with your friends and stay in touch with us for more such Magento 2 customization solutions.

Related Tutorial – How to Add Custom Field in Catalog Price Rule Form in Magento 2?

Happy Coding!

Click to rate this post!
[Total: 0 Average: 0]