WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Платформа для конвертации и монетизации трафика
функция не описана

Automattic\WooCommerce\Admin\API\Reports\Orders\Stats

DataStore::is_returning_customer() public WC 1.0

Check to see if an order's customer has made previous orders or not

{} Это метод класса: DataStore{}

Хуков нет.

Возвращает

true/false.

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

$result = DataStore::is_returning_customer( $order );
$order(массив) (обязательный)
WC_Order object.

Код DataStore::is_returning_customer() WC 4.7.1

<?php
public static function is_returning_customer( $order ) {
	$customer_id = \Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore::get_existing_customer_id_from_order( $order );

	if ( ! $customer_id ) {
		return false;
	}

	$oldest_orders = \Automattic\WooCommerce\Admin\API\Reports\Customers\DataStore::get_oldest_orders( $customer_id );

	if ( empty( $oldest_orders ) ) {
		return false;
	}

	$first_order       = $oldest_orders[0];
	$second_order      = isset( $oldest_orders[1] ) ? $oldest_orders[1] : false;
	$excluded_statuses = self::get_excluded_report_order_statuses();

	// Order is older than previous first order.
	if ( $order->get_date_created() < wc_string_to_datetime( $first_order->date_created ) &&
		! in_array( $order->get_status(), $excluded_statuses, true )
	) {
		self::set_customer_first_order( $customer_id, $order->get_id() );
		return false;
	}

	// The current order is the oldest known order.
	$is_first_order = (int) $order->get_id() === (int) $first_order->order_id;
	// Order date has changed and next oldest is now the first order.
	$date_change = $second_order &&
		$order->get_date_created() > wc_string_to_datetime( $first_order->date_created ) &&
		wc_string_to_datetime( $second_order->date_created ) < $order->get_date_created();
	// Status has changed to an excluded status and next oldest order is now the first order.
	$status_change = $second_order &&
		in_array( $order->get_status(), $excluded_statuses, true );
	if ( $is_first_order && ( $date_change || $status_change ) ) {
		self::set_customer_first_order( $customer_id, $second_order->order_id );
		return true;
	}

	return (int) $order->get_id() !== (int) $first_order->order_id;
}