Question

I've custom module of banner.

I want to add banner id as drop-down in price rules to select as custom field.

When, I select banner Id during sales rule then the particular banner must be activated on the website.

How can I do?

Was it helpful?

Solution

In order to add new field in Cart Price Rule, You need to create ui_component cause it created using it.

Follow Steps to add Custom Field in Cart Price Rule.

Vendor/Module/view/adminhtml/ui_component/sales_rule_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="rule_information" sortOrder="10">
    <field name="custom_field" formElement="select">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="source" xsi:type="string">sales_rule</item>
            </item>
        </argument>
        <settings>
            <validation>
                <rule name="required-entry" xsi:type="boolean">true</rule>
            </validation>
            <dataType>text</dataType>
            <label translate="true">Custom Field</label>
            <dataScope>custom_field</dataScope>
        </settings>
        <formElements>
        <select>
        <settings>
            <options class="Magento\Config\Model\Config\Source\Locale\Country"/>
        </settings>
        </select>
</formElements>
    </field>
</fieldset>

Clear cache using bin/magento c:c, Than check.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top