Skip to content
Advertisement

Disable tab on product page if it has no added WooCommerce products

I am using code that displays the Related Products tab on a single product page.

JavaScript

The code is working, but there is a small problem. If there are no manually added products in the “Related” tab, then all products of the store are displayed.

Tell me how you can fix this? How can I disable a tab if there are no added products in it?

I will be glad for your help!

Advertisement

Answer

You can use the same condition that you added in the new_handles_product_tab_content function. Only add tab if products found.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement