1

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?

1
  • it will not save to database right? Feb 14, 2019 at 11:12

1 Answer 1

3

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.

12
  • Can I add this in my exisitng custom module or create new module? May 28, 2018 at 12:57
  • You can do this in existing module.
    – anonymous
    May 28, 2018 at 12:58
  • but it is not working May 28, 2018 at 12:59
  • Did you clear cache ? What error are you getting ?
    – anonymous
    May 28, 2018 at 13:00
  • Yes, cache clear. not getting any error on price rule section. May 28, 2018 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.