Automattic\WooCommerce\Internal\Admin\Notes

NewSalesRecord::sum_sales_for_date()public staticWC 1.0

Returns the total of yesterday's sales.

Метод класса: NewSalesRecord{}

Хуков нет.

Возвращает

floatval.

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

$result = NewSalesRecord::sum_sales_for_date( $date );
$date(строка) (обязательный)
Date for sales to sum (i.e. YYYY-MM-DD).

Код NewSalesRecord::sum_sales_for_date() WC 7.3.0

public static function sum_sales_for_date( $date ) {
	$order_query = new \WC_Order_Query( array( 'date_created' => $date ) );
	$orders      = $order_query->get_orders();
	$total       = 0;

	foreach ( (array) $orders as $order ) {
		$total += $order->get_total();
	}

	return $total;
}