WC_Tracker::get_product_counts() – Get product totals based on product type.

You appear to be a bot. Output may be restricted

Description

Get product totals based on product type.

Usage

$array = WC_Tracker::get_product_counts();

Parameters

Returns

array

Source

File name: woocommerce/includes/class-wc-tracker.php
Lines:

1 to 12 of 12
  public static function get_product_counts() {
    $product_count          = array();
    $product_count_data     = wp_count_posts( 'product' );
    $product_count['total'] = $product_count_data->publish;

    $product_statuses = get_terms( 'product_type', array( 'hide_empty' => 0 ) );
    foreach ( $product_statuses as $product_status ) {
      $product_count[ $product_status->name ] = $product_status->count;
    }

    return $product_count;
  }
 

 View on GitHub View on Trac