0

I want to add Customer Group dropdown to Custom Options in Magento 2, the idea is to show Custom options based on the Customer Group in frontend.

I have a screenshot from my old Magento 1.9 store as an example:

enter image description here

Is there anyway to add Customer Group to Custom Options in Magento 2?

Thank you

Magento 2

enter image description here

  • where to want to add group option admin configuration, admin form, frontend where ? – Msquare Mar 26 at 13:51
0

Added in admin custom Form

    <field name="customer_group">
        <argument name="data" xsi:type="array">
            <item name="options" xsi:type="object">Magento\Customer\Model\Customer\Source\Group</item>
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">int</item>
                <item name="label" xsi:type="string" translate="true">Customer Group</item>
                <item name="formElement" xsi:type="string">multiselect</item>
                <item name="source" xsi:type="string">customer_group</item>
                <item name="dataScope" xsi:type="string">customer_group</item>
                <!-- <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                </item> -->
            </item>
        </argument>
    </field>

And system.xml also

            <field id="group_list"
                   translate="label"
                   type="select"
                   sortOrder="10"
                   showInDefault="1"
                   showInWebsite="1"
                   showInStore="1"
                   canRestore="1">
                <label>Select Customer Group</label>
                <source_model>Magento\Customer\Model\Customer\Source\Group</source_model>
            </field>

And if you want to add into forntend Form then get use this class Magento\Customer\Model\Customer\Source\Group

|improve this answer|||||
  • Hi, thank you for your answer, can you tell me exactly where I need to add this code? – Robert Mar 26 at 14:06
  • Please tell me in Wich file you want custom group list and where adminhtml or Frontend – Msquare Mar 26 at 14:17
  • you check screenshot? I need to add this Customer Group in the Magento 2 Admin in the Product in Custom Options, the same how is in that screeshot ... – Robert Mar 26 at 14:27
  • Please Add magento 2 screenshot where you want to add – Msquare Mar 26 at 15:01
  • Please check again, I edit my question and I add the screenshot. So Customer Group must be visible in the Catalog > Products > edit Product > Customizable Options tab. – Robert Mar 26 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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