Automattic\WooCommerce\Admin\API\Reports\Customers
DataStore::get_order_count()
Retrieve the amount of orders made by a customer.
Метод класса: DataStore{}
Хуков нет.
Возвращает
int|null
. Amount of orders for customer or null on failure.
Использование
$result = DataStore::get_order_count( $customer_id );
- $customer_id(int) (обязательный)
- Customer ID.
Код DataStore::get_order_count() DataStore::get order count WC 9.4.2
public static function get_order_count( $customer_id ) { global $wpdb; $customer_id = absint( $customer_id ); if ( 0 === $customer_id ) { return null; } $result = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( order_id ) FROM {$wpdb->prefix}wc_order_stats WHERE customer_id = %d", $customer_id ) ); if ( is_null( $result ) ) { return null; } return (int) $result; }