I am very new in Magento and from last few days I am trying to figure out how to add a Custom text field in the frontend for configurable product. I tried to do that but text-field text area is not showing up in the configurable product list of attributes. I can add drop down only.

I am looking for something that for example a customer want to buy a t-shirt and the text inside the t-shirt will be configurable from frontend product view page.

For example : custom text cost $5. There will be a checkbox in the product view page. When the customer click on it a text box will appear where he can add his text for the t-shirt. The $5 will automatically add with the checkout price.

I hope I am able to make you understand what I am trying to do. But, search a lot to figure it out but failed.



Check out this example it might help you

Step 1 - Create a file as Mypackage/Mymodule/Setup/InstallData.php and add the following code then

    namespace Mypackage\Mymodule\Setup;

    use Magento\Eav\Setup\EavSetup;
    use Magento\Eav\Setup\EavSetupFactory;
    use Magento\Framework\Setup\InstallDataInterface;
    use Magento\Framework\Setup\ModuleContextInterface;
    use Magento\Framework\Setup\ModuleDataSetupInterface;

    class InstallData implements InstallDataInterface

     * Customer setup factory
     * @var \Magento\Customer\Setup\CustomerSetupFactory
    private $_eavSetupFactory;

     * Init
     * @param \Magento\Customer\Setup\CustomerSetupFactory
     * $customerSetupFactory
    public function __construct(
        \Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
    ) {
        $this->_eavSetupFactory = $eavSetupFactory;

     * Installs DB schema for a module
     * @param ModuleDataSetupInterface $setup
     * @param ModuleContextInterface $context
     * @return void
    public function install(
        ModuleDataSetupInterface $setup,
        ModuleContextInterface $context
    ) {
        /** @var EavSetup $eavSetup */
        $eavSetup = $this->_eavSetupFactory->create([
            'setup' => $setup

        /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
            'is_feature', [
                'group'                   => 'Product Details',
                'type'                    => 'int',
                'backend'                 => '',
                'frontend'                => '',
                'label'                   => 'Is Feature',
                'input'                   => 'select',
                'source'                  =>
                'visible'                 => true,
                'default'                 => '0',
                'frontend'                => '',
                'unique'                  => false,
                'note'                    => '',
                'required'                => false,
                'sort_order'              => '',
                'global'                  =>
                'used_in_product_listing' => true,
                'visible_on_front'        => true

Step 2 - Go to project root directory and Run the following commands :

sudo rm -rf var/di var/generation var/cache
sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile
sudo php bin/magento clear:cache

Based on your question I recommend you to use an extension for this.

I have one extension in mind that can help you customize your configurable product in the way you want.

Dynamic Product Options for Magento® 2 (v2.5.3)

This extension provides many features to add custom and dynamic options to product.

There are other extensions as well.

Top 10 Magento 2 Custom Options Extensions

Hope this will work for you.

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.