WC_AJAX::get_customer_details
Get customer details via ajax.
Method of the class: WC_AJAX{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$result = WC_AJAX::get_customer_details();
WC_AJAX::get_customer_details() WC AJAX::get customer details code WC 10.5.0
public static function get_customer_details() {
$legacy_proxy = wc_get_container()->get( LegacyProxy::class );
$legacy_proxy->call_function( 'check_ajax_referer', 'get-customer-details', 'security' );
$user_id = absint(
$legacy_proxy->call_function( 'filter_input', INPUT_POST, 'user_id', FILTER_VALIDATE_INT )
);
if (
! current_user_can( 'edit_shop_orders' )
|| is_wp_error( Users::get_user_in_current_site( $user_id ) )
) {
wp_die( -1 );
}
$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 );
}