0

Want to hide More Information tab under catalog product view in Magento 2.3 if it's empty.

Not sure where to start, below is screenshot,

more info tab

I use M2.3 and theme is Porto (if that's necessary to know) I checked under /var/www/html/vendor/magento/module-catalog/view/frontend/layout/catalog_product_view.xml but not sure if this is where I need to make changes. Any help would be appreciated!

1 Answer 1

1

Inspect tab and look for id (button) and tab section div class or id.

<script>
require(['jquery'], function ($) {
    "use strict";
    $(document).ready(function () {
        alert($("#additional").find('tbody').html().trim().length);
        if ($("#additional").find('tbody').html().trim().length <= 0) {
            $("#tab-label-additional").hide();
        }else{

        }
    });
});
</script>

I this will fulfill your need in easy way.

Happy coding

9
  • Thanks Nilesh, I have inspected the tab and found this <a class="data switch" tabindex="-1" data-toggle="switch" href="#additional" id="tab-label-additional-title"> but I am not sure where should I add the jquery code you posted in your comment?
    – Neha
    Oct 21, 2020 at 12:51
  • you can add this in any .phtml file on the product view page Oct 21, 2020 at 12:56
  • sorry but not sure under what path because I have 2 different paths for .phtml files under product view one is var/www/html/vendor/magento/module-catalog/view/frontend/templates/product/view and another is under /var/www/html/app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view
    – Neha
    Oct 22, 2020 at 2:02
  • Use this one app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view and if possible look for addtocart.phtml and Also, please do not share "var/www/HTML" or whatever - Share the only paths like this ( just saying ) app/code or vendor Oct 22, 2020 at 7:40
  • I added the code to addtocart.phtml like this, <script> require(['jquery'], function ($) { "use strict"; $(document).ready(function () { if ($(".data switch").html().length <= 0) { $("#tab-label-additional-title").hide(); } }); }); </script> But the page is not loading correctly (cache cleared) Please let me know if added the code correctly
    – Neha
    Oct 23, 2020 at 1:46

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.