if statement - Woocommerce Tabs Conditional -


i running woocommerce plugin ( version 2.013) woocommerce tab manager extension (version 1.08). canvas child theme (version 0.1.0)

i'm trying show tabs products using conditional statement.

the tab manager doesn't allow conditional statements each tab. allows default global tabs or product specific tabs assigned in product edit page.

i found decent way show tabs in product page based on product attribute.

first thought share code because seems work. i'm still wondering if there better way this?

what create tab in tab manager , apply conditional statement it.

// video tabs product page - activate new video tab if attribute matches add_filter( 'woocommerce_product_tabs', 'video_tab' ); function video_tab( $tabs ) {     $type = array_shift(woocommerce_get_product_terms($_product->id, 'pa_type', 'names'));       if ( $type == "typea" ) {     $video_tab = array( 'video_tab' =>  array( 'title' => $type.' video', 'priority' => 9, 'callback' => 'video_tab_func' ) );           return array_merge( $video_tab, $tabs );     }         else {             return $tabs;            } }  // tab desctribtion          function video_tab_func() {     $type = array_shift(woocommerce_get_product_terms($_product->id, 'pa_type', 'names'));       if ( $type == "typea" ) {     echo do_shortcode( '[video src="/wp-content/uploads/2013/08/typea-video.mp4"]' );     } } 


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -