Skip to content

Instantly share code, notes, and snippets.

@jameskoster
Last active October 5, 2020 17:34
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save jameskoster/5133466 to your computer and use it in GitHub Desktop.
Save jameskoster/5133466 to your computer and use it in GitHub Desktop.
WooCommerce - Remove product data tabs
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
@tleung927
Copy link

Where is the functinos.php?

@ahmadsajid1989
Copy link

to tleung927

its your themes function.php man

@sunilw
Copy link

sunilw commented Oct 12, 2013

Warning: this removes the tab. But it also removes the content.

@unfulvio
Copy link

unfulvio commented Nov 6, 2013

Suppose I have a tab whose content is php conditionally generated. For some product the content of such tab could be empty/null. How can one make the tab disappear conditionally when such case occurs? If $tab['something'] has $content, display the tab; else if !$content, do not display. I understood that the filter above works globally not on a per-product basis.

@daniparra
Copy link

works like a charm! thank you.

@scsskid
Copy link

scsskid commented Feb 2, 2014

thank you!

@mgason
Copy link

mgason commented Apr 28, 2014

can you display say the content of the additional_information tab without displaying the tab?
I want to display the dimensions H,W,L and NOT weight

@mobex-web
Copy link

When I try to use this code to remove the additional information tab my footer gets messed up and becomes a small box down the center of my page. Same thing happens when I uncheck the box in the Attributes Visible on Page option. How can I fix?

Thank you.

@btribouillet
Copy link

@mobex-web I'm facing the same issue. Did you find a way to solve it?

Edited (fixed):

I guess woocommerce is using some float in the css. I added an overflow: hidden on my main container.

@drury2328
Copy link

Thank you!

@amadeann
Copy link

Thanks! I added the code to the end of the functions.php and worked well.

@heytricia
Copy link

Worked beautifully. I had the same issue with content below moving up. I justed added a clearfix via css, and problem solved. Thanks so much for sharing this!

@MZOG
Copy link

MZOG commented Feb 13, 2017

Does it remove all content or just hide?

@ymskliplybl
Copy link

Know this is a late comment. Put the code into theme functions, and site went down. Tried variations, also smashes the database. Tried the css solution but didn't work.

li.additional_information_tab {
display: none !important;

The entire site is in Danish language, except for the Woocommerce 'Read more' (after search) and 'Additional Information' tab. Think the theme is the issue.

Using Bridge mutlipurpose theme, and WP Bakery Visual Builder.

@tonimoni
Copy link

tonimoni commented Jul 6, 2017

Hi, this works as a charm for desktop, but on mobile I still have Description tab visible.
Do I need to edit code a bit? I know nothing on coding..so please be as detailed as possible.

@makeonlineshop
Copy link

Hello, thank you, but are you sure that it won’t make problems on products without additional information ?

It is said on Woocommerce doc that it will crash when the products do not have additional info.

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()

Thanks again.

@makeonlineshop
Copy link

Sorry, I tested and it works !

I checked products that didn't have additional information and products that have.

Both display well without the additional information tab.

I also hide the review tab:

add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); function woo_remove_product_tabs( $tabs ) { unset( $tabs['reviews'] ); // Remove the reviews tab unset( $tabs['additional_information'] ); // Remove the additional information tab return $tabs; }

@Dmelkonyan
Copy link

Thank you so much for posting this! Worked perfectly!

@chirag64bit
Copy link

Great ! work Perfectly

@idearian
Copy link

idearian commented Mar 7, 2018

Thank you, I tested and it works !

@ripfoxco
Copy link

Hi, thanks this works beautifully. One question though, is there any way to modify this code to only remove tabs on mobile devices? I would like to keep product descriptions on desktops but remove them on smaller devices, thanks in advance

@jorgeacruz
Copy link

Thanks Man

@muzammil-ahsan
Copy link

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment