WC_AJAX::get_customer_details()public staticWC 1.0

Get customer details via ajax.

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

Хуки из метода

Возвращает

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

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

$result = WC_AJAX::get_customer_details();

Код WC_AJAX::get_customer_details() WC 8.7.0

public static function get_customer_details() {
	check_ajax_referer( 'get-customer-details', 'security' );

	if ( ! current_user_can( 'edit_shop_orders' ) || ! isset( $_POST['user_id'] ) ) {
		wp_die( -1 );
	}

	$user_id  = absint( $_POST['user_id'] );
	$customer = new WC_Customer( $user_id );

	if ( has_filter( 'woocommerce_found_customer_details' ) ) {
		wc_deprecated_function( 'The woocommerce_found_customer_details filter', '3.0', 'woocommerce_ajax_get_customer_details' );
	}

	$data                  = $customer->get_data();
	$data['date_created']  = $data['date_created'] ? $data['date_created']->getTimestamp() : null;
	$data['date_modified'] = $data['date_modified'] ? $data['date_modified']->getTimestamp() : null;

	unset( $data['meta_data'] );

	$customer_data = apply_filters( 'woocommerce_ajax_get_customer_details', $data, $customer, $user_id );
	wp_send_json( $customer_data );
}