Menu Close

WooCommerce: Related Products in a Custom Tab @ Single Product Page

default

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 in a Tab

PHP Snippet: Move Related Products to a Tab – WooCommerce Single Product Page

/**
 * @snippet       Related Products in a New Product Tab - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 7
 * @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', 'bbloomer_new_product_tab' );

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

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

function bbloomer_new_product_tab_content() {
   woocommerce_output_related_products();
}
View Source
Posted in WooCommerce Tips