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

DataStore::set_customer_first_order()protected staticWC 1.0

Set a customer's first order and all others to returning.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$result = DataStore::set_customer_first_order( $customer_id, $order_id );
$customer_id(int) (обязательный)
Customer ID.
$order_id(int) (обязательный)
Order ID.

Код DataStore::set_customer_first_order() WC 8.7.0

protected static function set_customer_first_order( $customer_id, $order_id ) {
	global $wpdb;
	$orders_stats_table = self::get_db_table_name();

	$wpdb->query(
		$wpdb->prepare(
			// phpcs:ignore Generic.Commenting.Todo.TaskFound
			// TODO: use the %i placeholder to prepare the table name when available in the the minimum required WordPress version.
			// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
			"UPDATE {$orders_stats_table} SET returning_customer = CASE WHEN order_id = %d THEN false ELSE true END WHERE customer_id = %d",
			$order_id,
			$customer_id
		)
	);
}