This is a simple snippet that will allow you to move the Related Products from below the tabs to inside the single product tabs, in a brand new tab.

WooCommerce Related Products Tab
WooCommerce Related Products Tab WooCommerce Related Products Tab

PHP Snippet: Move Related Products to a Tab – WooCommerce


/**
 * @snippet       Checkbox to display Custom Product Badge Part 1 - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @source        https://businessbloomer.com/?p=17419
 * @author        Rodolfo Melogli
 * @compatible    Woo 3.5.3
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

// First, let's remove related products from their original position

remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);

// Second, let's add a new tab

add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );

function woo_new_product_tab( $tabs ) {
	
$tabs['related_products'] = array(
	'title' 	=> __( 'Try it with', 'woocommerce' ),
	'priority' 	=> 50,
	'callback' 	=> 'woo_new_product_tab_content'
);
	return $tabs;
}

// Third, let's put the related products inside

function woo_new_product_tab_content() {
woocommerce_output_related_products();
}

Share:

Leave a Reply