[#18223] Filter results for related products

This commit is contained in:
Fulvio Notarstefano 2017-12-29 12:18:50 +08:00
parent eb60a17818
commit b8beb703ef
1 changed files with 5 additions and 0 deletions

View File

@ -855,6 +855,11 @@ function wc_get_related_products( $product_id, $limit = 5, $exclude_ids = array(
set_transient( $transient_name, $related_posts, DAY_IN_SECONDS );
}
$related_posts = apply_filters( 'woocommerce_related_products', $related_posts, $product_id, array(
'limit' => $limit,
'excluded_ids' => $exclude_ids,
) );
shuffle( $related_posts );
return array_slice( $related_posts, 0, $limit );