corsonr
8/5/2013 - 10:41 AM

WooCommerce - Place "related products" within a tab

WooCommerce - Place "related products" within a tab

<?php
/*
 * Place this code in functions.php in the theme folder
 */

/*
 * Remove related products from product page
 */
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);

/*
 * Register custom tab
 */
function woo_custom_product_tab( $tabs ) {
   
    $custom_tab = array( 
      		'custom_tab' =>  array( 
    							'title' => __('Custom Tab','woocommerce'), 
    							'priority' => 9, 
    							'callback' => 'woo_custom_product_tab_content' 
    						)
    				);

    return array_merge( $custom_tab, $tabs );
}

/*
 * Place content in custom tab (related products in this sample)
 */
function woo_custom_product_tab_content() {
	woocommerce_related_products();
}
add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tab' );