I've made global product description tab as well as global attribute with yes/no values. Attribute default settings is set to "no". I want to show this additional tab only for products whose attribute value is set to yes. How can I achieve this?

1 Answer 1


Just override the attributes.phtml file in your theme like so.


 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

// @codingStandardsIgnoreFile

 * Product additional attributes template
 * @var $block \Magento\Catalog\Block\Product\View\Attributes
    $_helper = $this->helper('Magento\Catalog\Helper\Output');
    $_product = $block->getProduct();
<?php if ($_additional = $block->getAdditionalData()): ?>
    <?php $canShow = $_additional['/custom_attribute_code/']['value']; ?>
    <?php if($canShow) : ?>
        <div class="additional-attributes-wrapper table-wrapper">
            <table class="data table additional-attributes" id="product-attribute-specs-table">
                <caption class="table-caption"><?= /* @escapeNotVerified */ __('More Information') ?></caption>
                <?php foreach ($_additional as $_data): ?>
                        <th class="col label" scope="row"><?= $block->escapeHtml(__($_data['label'])) ?></th>
                        <td class="col data" data-th="<?= $block->escapeHtml(__($_data['label'])) ?>"><?= /* @escapeNotVerified */ $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
                <?php endforeach; ?>
    <?php endif; ?>
<?php endif;?>

<?php $canShow = $_additional['/custom_attribute_code/']['value']; ?>

Replace '/custom_attribute_code/' with your own.

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.