Created
April 20, 2017 01:00
-
-
Save grayayer/d231fb685f93b92547058de9900d5c50 to your computer and use it in GitHub Desktop.
remove related products from the bottom of product pages in Woocommerce
This file contains hidden or 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
/* remove related products from the bottom of product pages in Woocommerce */ | |
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 ); | |
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); | |
add_action( 'woocommerce_after_single_product_summary', 'related_upsell_products', 15 ); | |
function related_upsell_products() { | |
global $product; | |
if ( isset( $product ) && is_product() ) { | |
$upsells = $product->get_upsells(); | |
if ( sizeof( $upsells ) > 0 ) { | |
woocommerce_upsell_display(); | |
} else { | |
woocommerce_upsell_display(); | |
woocommerce_output_related_products(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment