Last active
August 29, 2015 14:17
-
-
Save wp-kitten/f4d87fe697fabce93e37 to your computer and use it in GitHub Desktop.
WooCommerce: Display upsells instead of related products
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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