Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
Utils::get_random_order_seed
Get the random order seed for a Product Collection.
Метод класса: Utils{}
Хуков нет.
Возвращает
int. Random order seed.
Использование
$result = Utils::get_random_order_seed( $query_id, $query_context );
- $query_id(int) (обязательный)
- Product Collection query ID.
- $query_context(массив)
- Product Collection query context.
По умолчанию:array()
Список изменений
| С версии 11.0.0 | Введена. |
Код Utils::get_random_order_seed() Utils::get random order seed WC 11.3.0
public static function get_random_order_seed( $query_id, $query_context = array() ) {
$seed_context = array(
'blog_id' => get_current_blog_id(),
'queried_object_id' => get_queried_object_id(),
'query_id' => absint( $query_id ),
'rotation_key' => wp_date( 'Y-m-d' ),
'query' => $query_context,
);
$encoded_seed_context = wp_json_encode( $seed_context );
$seed_hash = (int) sprintf( '%u', crc32( is_string( $encoded_seed_context ) ? $encoded_seed_context : '' ) );
return ( $seed_hash % 2147483646 ) + 1;
}