Skip to content

Instantly share code, notes, and snippets.

@pavlo-bondarchuk
Created May 21, 2020 15:28
Show Gist options
  • Select an option

  • Save pavlo-bondarchuk/fa09b18caf7edee02be2792ddb3d899c to your computer and use it in GitHub Desktop.

Select an option

Save pavlo-bondarchuk/fa09b18caf7edee02be2792ddb3d899c to your computer and use it in GitHub Desktop.
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment