HIDE TAB additional information ? Or any solution without editing all products ?
-
hello,
Some old products have additional information tab displayed and I would like to hide this tab for all my products, hide it totally on my shop.
Can you tell me what is the correct code to hide this tab only when it is displayed to avoid the error message explained below ?
Thank you so much.
I read here:
https://docs.woocommerce.com/document/editing-product-data-tabs/Please note that the “Additional Information” tab will only show if the product has weight, dimensions or attributes (not used for variation for variable products). If you try to apply a change to that tab and if the product does not have weight, dimensions or attribute, you will get an error message similar to :
Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in /mysite/wp-content/plugins/woocommerce/templates/single-product/tabs/tabs.php on line 35
In that case you have to use WooCommerce conditional tags:
has_attributes()
has_dimensions()
has_weight()add_filter( ‘woocommerce_product_tabs’, ‘woo_rename_tabs’, 98 );
function woo_rename_tabs( $tabs ) {
global $product;
if( $product->has_attributes() || $product->has_dimensions() || $product->has_weight() ) { // Check if product has attributes, dimensions or weight
$tabs[‘additional_information’][‘title’] = __( ‘Product Data’ ); // Rename the additional information tab
}return $tabs;
}
- The topic ‘HIDE TAB additional information ? Or any solution without editing all products ?’ is closed to new replies.