Home › Forums › WoodMart support forum › Conditionally show product tab
Conditionally show product tab
- This topic has 13 replies, 3 voices, and was last updated 5 years, 5 months ago by twgerber.
-
AuthorPosts
-
July 2, 2019 at 2:00 pm #131009
twgerberParticipantIn the woodmart theme I have set up an additional tab called “Delivery Forms”.
This tab is only applicable to certain product categories.
Can I set up a condition so it doesn’t show for certain categories?
Thank you
For example it should show for Dog products: https://vitalplanet.com/supplements/flora-dog-20-billion-probiotic-powder-vs/
But not for human products like: https://vitalplanet.com/supplements/vital-flora-womens-daily-55-probiotic/July 2, 2019 at 3:57 pm #131030
Elise NoromitMemberHello,
Product page and tabs are Woocommerce functionality, and Woocommerce does not provide the option by default.
Perhaps you can try searching for a plugin.
Best Regards
July 3, 2019 at 2:21 pm #131161
twgerberParticipantI will look. Since I set it up on the theme I thought the tab was under theme control
Thx
July 3, 2019 at 3:25 pm #131176
Elise NoromitMemberHello,
The theme provides the option of an additional tab on the product page. You can create HTML block for dogs and insert it in the additional tab for all dogs products. https://xtemos.com/docs/woodmart/product-page-options/
Best Regards
July 5, 2019 at 4:49 pm #131512
twgerberParticipantCan I not add some custom CSS to hide the extra tab for a single products like:
/* removes the image on product id = 8885 */
.postid-8885 .woodmart_additional_tab_tab {
display:none;
}I must not have my CSS quite right because it’s not working 😉
July 5, 2019 at 5:49 pm #131516
newsprinceParticipant1st. Install this plug-in
https://wordpress.org/plugins/code-snippets/
2nd. Create a new snippet and paste the following code:
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); function woo_remove_product_tabs( $tabs ) { if ( has_term( array('human-health'), 'product_cat') ){ unset( $tabs['additional_information'] ); // Remove the additional information tab //unset( $tabs['woodmart_custom_tab'] ); // Remove the custom information tab } return $tabs; }
Now on category human health the tab will not be shown.
July 5, 2019 at 6:01 pm #131518
twgerberParticipantThanks I will try this.
July 5, 2019 at 6:11 pm #131519
twgerberParticipantDoesn’t seem to do anything 🙁
July 5, 2019 at 6:16 pm #131520
newsprinceParticipantDid you activate the snippet (Save and activate – Run everywhere)?
Did you clear your cache?
July 5, 2019 at 6:21 pm #131522
twgerberParticipantYes, yes and yes 😉
I will go thru it again.
July 5, 2019 at 6:25 pm #131523
twgerberParticipantNo still not working. I even uncommented the two unset lines.
Shows as active and I cleared WP Rocket cache.
July 5, 2019 at 6:28 pm #131524
newsprinceParticipantSorry it was Woodmart’s additional tab. Try this code again
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 ); function woo_remove_product_tabs( $tabs ) { if ( has_term( array('human-health'), 'product_cat') ){ unset( $tabs['woodmart_additional_tab'] ); // Remove the additional information tab //unset( $tabs['woodmart_custom_tab'] ); // Remove the custom information tab } return $tabs; }
Clear cache after
July 5, 2019 at 6:29 pm #131525
twgerberParticipantI exported the snippet to add.
July 5, 2019 at 6:30 pm #131526
twgerberParticipantThat did it!!!
Thanks!
-
AuthorPosts
- You must be logged in to create new topics. Login / Register