get_rating_counts_for_product() public static méthode

Get product rating count for a product. Please note this is not cached.
Since: 2.7.0
public static get_rating_counts_for_product ( WC_Product &$product ) : array
$product WC_Product
Résultat array of integers
 /**
  * Read product data. Can be overridden by child classes to load other props.
  *
  * @param WC_Product
  * @since 2.7.0
  */
 protected function read_product_data(&$product)
 {
     $id = $product->get_id();
     if ('' === ($review_count = get_post_meta($id, '_wc_review_count', true))) {
         WC_Comments::get_review_count_for_product($product);
     } else {
         $product->set_review_count($review_count);
     }
     if ('' === ($rating_counts = get_post_meta($id, '_wc_rating_count', true))) {
         WC_Comments::get_rating_counts_for_product($product);
     } else {
         $product->set_rating_counts($rating_counts);
     }
     if ('' === ($average_rating = get_post_meta($id, '_wc_average_rating', true))) {
         WC_Comments::get_average_rating_for_product($product);
     } else {
         $product->set_average_rating($average_rating);
     }
     $product->set_props(array('sku' => get_post_meta($id, '_sku', true), 'regular_price' => get_post_meta($id, '_regular_price', true), 'sale_price' => get_post_meta($id, '_sale_price', true), 'price' => get_post_meta($id, '_price', true), 'date_on_sale_from' => get_post_meta($id, '_sale_price_dates_from', true), 'date_on_sale_to' => get_post_meta($id, '_sale_price_dates_to', true), 'total_sales' => get_post_meta($id, 'total_sales', true), 'tax_status' => get_post_meta($id, '_tax_status', true), 'tax_class' => get_post_meta($id, '_tax_class', true), 'manage_stock' => get_post_meta($id, '_manage_stock', true), 'stock_quantity' => get_post_meta($id, '_stock', true), 'stock_status' => get_post_meta($id, '_stock_status', true), 'backorders' => get_post_meta($id, '_backorders', true), 'sold_individually' => get_post_meta($id, '_sold_individually', true), 'weight' => get_post_meta($id, '_weight', true), 'length' => get_post_meta($id, '_length', true), 'width' => get_post_meta($id, '_width', true), 'height' => get_post_meta($id, '_height', true), 'upsell_ids' => get_post_meta($id, '_upsell_ids', true), 'cross_sell_ids' => get_post_meta($id, '_crosssell_ids', true), 'purchase_note' => get_post_meta($id, '_purchase_note', true), 'default_attributes' => get_post_meta($id, '_default_attributes', true), 'category_ids' => $this->get_term_ids($product, 'product_cat'), 'tag_ids' => $this->get_term_ids($product, 'product_tag'), 'shipping_class_id' => current($this->get_term_ids($product, 'product_shipping_class')), 'virtual' => get_post_meta($id, '_virtual', true), 'downloadable' => get_post_meta($id, '_downloadable', true), 'gallery_image_ids' => array_filter(explode(',', get_post_meta($id, '_product_image_gallery', true))), 'download_limit' => get_post_meta($id, '_download_limit', true), 'download_expiry' => get_post_meta($id, '_download_expiry', true), 'image_id' => get_post_thumbnail_id($id)));
     // Gets extra data associated with the product.
     // Like button text or product URL for external products.
     foreach ($product->get_extra_data_keys() as $key) {
         $function = 'set_' . $key;
         if (is_callable(array($product, $function))) {
             $product->{$function}(get_post_meta($product->get_id(), '_' . $key, true));
         }
     }
 }
 /**
  * Sync product rating count. Can be called statically.
  *
  * @deprecated 2.7.0
  * @param  int $post_id
  */
 public static function sync_rating_count($post_id)
 {
     wc_deprecated_function('WC_Product::sync_rating_count', '2.7', 'WC_Comments::get_rating_counts_for_product or leave to CRUD.');
     $counts = WC_Comments::get_rating_counts_for_product(wc_get_product($post_id));
     update_post_meta($post_id, '_wc_rating_count', $counts);
 }