---
title: "Magento 2: Hide Product Gift Option Tab Based on System Configuration"
url: "https://magecomp.com/blog/magento-2-hide-product-gift-option-tab-based-on-system-configuration/"
date: "2024-12-16T13:22:41+00:00"
modified: "2025-02-12T09:57:34+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 791
reading_time: "4 min read"
summary: "Hello Magento friends,"
description: "Learn How to Show or Hide Product Gift Option Tab Based on System Configuration in Magento 2"
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Magento 2: How to Retrieve Masked ID from the Cart ID"
    url: "https://magecomp.com/blog/magento-2-retrieve-masked-id-from-the-cart-id/"
  - title: "Magento 2: How to Override Template using Helper Function"
    url: "https://magecomp.com/blog/magento-2-override-template-using-helper-function/"
  - title: "How to Add Custom Tab in Customer Account Section in Magento 2?"
    url: "https://magecomp.com/blog/add-custom-tab-in-customer-account-section-magento-2/"
---

# Magento 2: Hide Product Gift Option Tab Based on System Configuration

_Published: December 16, 2024_  
_Author: Dhiren Vasoya_  

![Hide Product Gift Option Tab Based on System Configuration in M2](https://magecomp.com/blog/wp-content/uploads/2024/12/Hide-Product-Gift-Option-Tab-Based-on-System-Configuration-in-M2-1024x512.webp)

**Hello Magento friends,**

In today’s Magento 2 tutorial, I will show How to Hide the Product Gift Option Tab Based on System Configuration.

[![Magento version upgrade](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Version-Upgrade-CTA-2-2.webp)](https://magecomp.com/services/magento-upgrade-services/)Magento 2 provides a gift options tab in the backend configuration of products to allow store owners to let customers [**add gift messages**](https://magecomp.com/blog/enable-gift-message-in-magento-2/) to their purchases. While some products may not require gift options, at that time you do not require a gift options tab in the backend configuration. Follow the below steps to Hide Product Gift Option Tab Based on System Configuration in Magento 2.

## Steps to Hide Product Gift Option Tab Based on System Configuration in Magento 2:
**Step 1:** Create a **di.xml** file in the given below path

**{{magento_root}}\app\code\Vendor\Extension\etc\adminhtml\di.xml

Then add the code as follows

```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="MagentoCatalogUiDataProviderProductFormModifierPool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="advancedCustomOptions" xsi:type="array">
                    <item name="class" xsi:type="string">VendorExtensionUiDataProviderProductForm</item>
                    <item name="sortOrder" xsi:type="number">20</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
</config>
```

**Step 2:** Create a **system.xml** in the following path

**{{magento_root}}\app\code\Vendor\Extension\etc\adminhtml\system.xml**

Now add the given below code

```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <tab id="vendor" translate="label" sortOrder="100">
            <label>Vendor</label>
        </tab>
                    <label>General Settings</label>
            <tab>vendor</tab>
            <resource>Vendor_Extension::config</resource>
            <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Hide Product Gift option</label>
                <field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Enable</label>
                    <source_model>MagentoConfigModelConfigSourceYesno</source_model>
                </field>
            </group>
            </system>
</config>
```

[![Magento Malware Removal](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-Malware-Removal-CTA-2.webp)](https://magecomp.com/magento-malware-removal.html)**Step 3:** Create an **acl.xml** in below-mentioned path

**{{magento_root}}\app\code\Vendor\Extension\etc\acl.xml**

Now add the following piece of code

```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Magento_Backend::stores">
                      <resource id="Magento_Backend::stores_settings">
            <resource id="Magento_Config::config">
                        <resource id="Vendor_Extension::config" title="Vendor Extension Configuration" sortOrder="10"/>
                    </resource>
                </resource>
        </resource>
            </resource>
        </resources>
    </acl>
</config>
```

**Step 4:** Create a **ProductForm.php** in the given below path.

**{{magento_root}}\app\code\Vendor\Extension\Ui\DataProvider\ProductForm.php**

Then add the code as below

```
<?php
namespace VendorExtensionUiDataProvider;

use MagentoCatalogUiDataProviderProductFormModifierAbstractModifier;
use MagentoCatalogModelLocatorLocatorInterface;
use MagentoFrameworkAppRequestInterface;
use MagentoFrameworkViewLayoutFactory;
use MagentoFrameworkAppConfigScopeConfigInterface;

class ProductForm extends AbstractModifier
{
    /**
     * @var LocatorInterface
     */
    protected $locator;

    protected $scopeConfig;

    /**
     * @var RequestInterface
     */
    protected $request;

    /**
     * @var LayoutFactory
     */
    private $layoutFactory;

    public function __construct(
        LocatorInterface $locator,
        RequestInterface $request,
        LayoutFactory $layoutFactory,
        ScopeConfigInterface $scopeConfig
    ) {
        $this->locator = $locator;
        $this->request = $request;
        $this->layoutFactory = $layoutFactory;
        $this->scopeConfig = $scopeConfig;
    }

    public function modifyMeta(array $meta)
{
    // Check if the configuration flag is enabled
    $isEnable = $this->scopeConfig->isSetFlag(
        'general_settings/general/enabled',
        MagentoStoreModelScopeInterface::SCOPE_STORE
    );

    if ($isEnable && isset($meta['gift-options'])) {
        $meta['gift-options']['arguments']['data']['config']['visible'] = false;
        $meta['gift-options']['arguments']['data']['config']['canShow'] = false;
    }

    return $meta;
}


    /**
     * {@inheritdoc}
     */
    public function modifyData(array $data)
    {
        return $data;
    }

    /**
     * Get product type
     *
     * @return null|string
     */
    private function getProductType()
    {
        return (string)$this->request->getParam('type', $this->locator->getProduct()->getTypeId());
    }
}
```

**Output:**

If the Hide Product Gift Option is set to No,

![Hide product gift option No](https://magecomp.com/blog/wp-content/uploads/2024/12/Hide-product-gift-option-No-1024x465.webp)it will display the Gift Options tab for the product

![Gift option tab available](https://magecomp.com/blog/wp-content/uploads/2024/12/Gift-option-tab-available-1024x438.webp)If the Hide Product Gift Option is set to Yes,

![Hide product gift option Yes](https://magecomp.com/blog/wp-content/uploads/2024/12/Hide-product-gift-option-Yes-1024x464.webp)it will not display the Gift Options tab for the product

![Gift option tab not available](https://magecomp.com/blog/wp-content/uploads/2024/12/Gift-option-tab-not-available-1024x415.webp)[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Speed-Performance-Optimization-Services-CTA-2.webp)](https://magecomp.com/magento-performance-optimization.html)

## Conclusion:
Hence, this way you can hide and unhide the product gift option tab based on system configuration in Magento 2. Share your doubts through the comment box and stay with us for more such tutorials.

**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/magento-2-hide-product-gift-option-tab-based-on-system-configuration/](https://magecomp.com/blog/magento-2-hide-product-gift-option-tab-based-on-system-configuration/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-03 20:36:04 UTC_  
