Allow disabling of shuffling related posts via `woocommerce_product_related_posts_shuffle` filter. #23558

This filter ensures backwards compatibility is maintained.
This commit is contained in:
Ben Huson 2019-04-30 18:36:02 +01:00
parent 563b84ece4
commit 70064b5eb1
1 changed files with 3 additions and 1 deletions

View File

@ -886,7 +886,9 @@ function wc_get_related_products( $product_id, $limit = 5, $exclude_ids = array(
)
);
shuffle( $related_posts );
if ( apply_filters( 'woocommerce_product_related_posts_shuffle', true ) ) {
shuffle( $related_posts );
}
return array_slice( $related_posts, 0, $limit );
}