wc_update_product_lookup_tables_rating_count()WC 3.6.0

Populate rating count lookup table data for products.

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wc_update_product_lookup_tables_rating_count( $rows );
$rows(массив) (обязательный)
Rows of rating counts to update in lookup table.

Список изменений

С версии 3.6.0 Введена.

Код wc_update_product_lookup_tables_rating_count() WC 8.7.0

function wc_update_product_lookup_tables_rating_count( $rows ) {
	if ( ! $rows || ! is_array( $rows ) ) {
		return;
	}
	global $wpdb;

	foreach ( $rows as $row ) {
		$count = array_sum( (array) maybe_unserialize( $row['meta_value'] ) );
		$wpdb->update(
			$wpdb->wc_product_meta_lookup,
			array(
				'rating_count' => absint( $count ),
			),
			array(
				'product_id' => absint( $row['post_id'] ),
			)
		);
	}
}