How to Hide an Empty Custom Tab in Magento 2

How to Hide an Empty Custom Tab in Magento 2

According to a study by Google

  • The visitors will judge the online store as beautiful or not in the only 1/50th to 1/20th of a second.
  • Visually complex websites are consistently rated as less beautiful than their simpler equivalent.

A beautiful website means a visually appealing, simpler, and easy navigation website.

As a Magento 2 store owner, you would want to offer a shopping platform that would not confuse or irritate the shoppers! Removing unnecessary elements from the frontend is quite important as to not distract the visitors from their main goal (and obviously, ours ), i.e., making a purchase!

Keeping this in mind, I have come up with a programmatic method to hide an empty custom tab in Magento 2. With this method, hide unnecessary tabs from the product page.

For example, a product page shows the FAQ section. However, for products with no FAQs, you’d not want to show an empty FAQ tab. To hide such empty custom tabs from the storefront, implement the below method.

Method to Hide an Empty Custom Tab in Magento 2:

  1. Create registration.php at app/code/[VendorName]/[ModuleName]
  2. Create module.xml at app/code/[VendorName]/[ModuleName]
  3. Create catalog_product_view.xml at app/code/[VendorName]/[ModuleName]/view/frontend/layout
  4. Create custom_tab.phtml at app/code/[VendorName]/[ModuleName]/view/frontend/templates/product/view/details/

That’s it.

With the above steps, make your Magento 2 store presentable, simpler, and hide unnecessary custom tabs.

5
(based on 6 Reviews)

Sanjay is a co-founder at Meetanshi. He is a certified Magento developer who loves creating Magento E-commerce solutions. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a Reply