Remove unneeded comments

This commit is contained in:
Mike Jolley 2016-10-17 17:07:19 +01:00
parent 34f579cfc4
commit 68282e9661
1 changed files with 6 additions and 20 deletions

View File

@ -753,6 +753,7 @@ function wc_get_product_visibility_options() {
} }
/** /**
<<<<<<< 34f579cfc4db9f4642b71f2af4f08df516d644b7
* Get min/max price meta query args. * Get min/max price meta query args.
* *
* @since 2.7.0 * @since 2.7.0
@ -789,7 +790,7 @@ function wc_get_min_max_price_meta_query( $args ) {
); );
/** /**
* Get relateed products. * Get related products based on product category and tags.
* *
* @since 2.7.0 * @since 2.7.0
* @param int $product_id Product ID. * @param int $product_id Product ID.
@ -808,37 +809,22 @@ function wc_get_related_products( $product_id, $limit = 5, $exclude_ids = array(
// We want to query related posts if they are not cached, or we don't have enough. // We want to query related posts if they are not cached, or we don't have enough.
if ( false === $related_posts || count( $related_posts ) < $limit ) { if ( false === $related_posts || count( $related_posts ) < $limit ) {
// Related products are found from category and tags. $cats_array = apply_filters( 'woocommerce_product_related_posts_relate_by_category', true, $product_id ) ? wc_get_related_terms( $product_id, 'product_cat' ) : array();
if ( apply_filters( 'woocommerce_product_related_posts_relate_by_category', true, $product_id ) ) { $tags_array = apply_filters( 'woocommerce_product_related_posts_relate_by_tag', true, $product_id ) ? wc_get_related_terms( $product_id, 'product_tag' ) : array();
$cats_array = wc_get_related_terms( $product_id, 'product_cat' );
} else {
$cats_array = array();
}
if ( apply_filters( 'woocommerce_product_related_posts_relate_by_tag', true, $product_id ) ) {
$tags_array = wc_get_related_terms( $product_id, 'product_tag' );
} else {
$tags_array = array();
}
// Don't bother if none are set, unless woocommerce_product_related_posts_force_display is set to true in which case all products are related. // Don't bother if none are set, unless woocommerce_product_related_posts_force_display is set to true in which case all products are related.
if ( empty( $cats_array ) && empty( $tags_array ) && ! apply_filters( 'woocommerce_product_related_posts_force_display', false, $product_id ) ) { if ( empty( $cats_array ) && empty( $tags_array ) && ! apply_filters( 'woocommerce_product_related_posts_force_display', false, $product_id ) ) {
$related_posts = array(); $related_posts = array();
} else { } else {
// Generate query - but query an extra 10 results to give the appearance of random results. // Generate query - but query an extra 10 results to give the appearance of random results when later shuffled.
$query = apply_filters( 'woocommerce_product_related_posts_query', wc_get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit + 10 ), $product_id ); $related_posts = $wpdb->get_col( implode( ' ', apply_filters( 'woocommerce_product_related_posts_query', wc_get_related_products_query( $cats_array, $tags_array, $exclude_ids, $limit + 10 ), $product_id ) ) );
// Get the posts.
$related_posts = $wpdb->get_col( implode( ' ', $query ) );
} }
set_transient( $transient_name, $related_posts, DAY_IN_SECONDS ); set_transient( $transient_name, $related_posts, DAY_IN_SECONDS );
} }
// Randomise the results.
shuffle( $related_posts ); shuffle( $related_posts );
// Limit the returned results.
return array_slice( $related_posts, 0, $limit ); return array_slice( $related_posts, 0, $limit );
} }