Automattic\WooCommerce\Admin\API\Reports\Orders\Stats
Segmenter::get_segment_selections_product_level()
Returns column => query mapping to be used for product-related product-level segmenting query (e.g. products sold, revenue from product X when segmenting by category).
Method of the class: Segmenter{}
No Hooks.
Return
Array
. Column => SELECT query mapping.
Usage
// protected - for code of main (parent) or child class $result = $this->get_segment_selections_product_level( $products_table );
- $products_table(string) (required)
- Name of SQL table containing the product-level segmenting info.
Segmenter::get_segment_selections_product_level() Segmenter::get segment selections product level code WC 8.7.0
protected function get_segment_selections_product_level( $products_table ) { $columns_mapping = array( 'num_items_sold' => "SUM($products_table.product_qty) as num_items_sold", 'total_sales' => "SUM($products_table.product_gross_revenue) AS total_sales", 'coupons' => 'SUM( coupon_lookup_left_join.discount_amount ) AS coupons', 'coupons_count' => 'COUNT( DISTINCT( coupon_lookup_left_join.coupon_id ) ) AS coupons_count', 'refunds' => "SUM( CASE WHEN $products_table.product_gross_revenue < 0 THEN $products_table.product_gross_revenue ELSE 0 END ) AS refunds", 'taxes' => "SUM($products_table.tax_amount) AS taxes", 'shipping' => "SUM($products_table.shipping_amount) AS shipping", 'net_revenue' => "SUM($products_table.product_net_revenue) AS net_revenue", ); return $columns_mapping; }