Skip to content

Instantly share code, notes, and snippets.

@wp-kitten
Last active August 29, 2015 14:17
Show Gist options
  • Save wp-kitten/f4d87fe697fabce93e37 to your computer and use it in GitHub Desktop.
Save wp-kitten/f4d87fe697fabce93e37 to your computer and use it in GitHub Desktop.
WooCommerce: Display upsells instead of related products
<?php
// @file: content-single-product.php
/*
* Display upsells if any
* - removes duplicated product information
*/
global $product;
$upsells = $product->get_upsells();
/**
* woocommerce_after_single_product_summary hook
*
* @hooked woocommerce_output_product_data_tabs - 10
* @hooked woocommerce_output_related_products - 20
*/
if (empty($upsells))
{
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
}
else
{
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
}
do_action( 'woocommerce_after_single_product_summary' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment