WordPress at Your Fingertips
function is not described

WC_Tracker::get_order_totals() private WC 5.4.0

Get order totals.

{} It's a method of the class: WC_Tracker{}

No Hooks.

Return

Array.

Usage

$result = WC_Tracker::get_order_totals();

Changelog

Since 5.4.0 Introduced.

Code of WC_Tracker::get_order_totals() WC 5.9.0

private static function get_order_totals() {
	global $wpdb;

	$gross_total = $wpdb->get_var(
		"
		SELECT
			SUM( order_meta.meta_value ) AS 'gross_total'
		FROM {$wpdb->prefix}posts AS orders
		LEFT JOIN {$wpdb->prefix}postmeta AS order_meta ON order_meta.post_id = orders.ID
		WHERE order_meta.meta_key =  '_order_total'
			AND orders.post_status in ( 'wc-completed', 'wc-refunded' )
		GROUP BY order_meta.meta_key
	"
	);

	if ( is_null( $gross_total ) ) {
		$gross_total = 0;
	}

	$processing_gross_total = $wpdb->get_var(
		"
		SELECT
			SUM( order_meta.meta_value ) AS 'gross_total'
		FROM {$wpdb->prefix}posts AS orders
		LEFT JOIN {$wpdb->prefix}postmeta AS order_meta ON order_meta.post_id = orders.ID
		WHERE order_meta.meta_key =  '_order_total'
			AND orders.post_status = 'wc-processing'
		GROUP BY order_meta.meta_key
	"
	);

	if ( is_null( $processing_gross_total ) ) {
		$processing_gross_total = 0;
	}

	return array(
		'gross'            => $gross_total,
		'processing_gross' => $processing_gross_total,
	);
}