WC_API_Customers::get_customer_by_email()
Get the customer for the given email
Метод класса: WC_API_Customers{}
Хуков нет.
Возвращает
Массив|WP_Error
.
Использование
$WC_API_Customers = new WC_API_Customers(); $WC_API_Customers->get_customer_by_email( $email, $fields );
- $email(строка) (обязательный)
- the customer email
- $fields(массив)
- -
По умолчанию: null
Список изменений
С версии 2.1 | Введена. |
Код WC_API_Customers::get_customer_by_email() WC API Customers::get customer by email WC 7.7.2
public function get_customer_by_email( $email, $fields = null ) { try { if ( is_email( $email ) ) { $customer = get_user_by( 'email', $email ); if ( ! is_object( $customer ) ) { throw new WC_API_Exception( 'woocommerce_api_invalid_customer_email', __( 'Invalid customer email', 'woocommerce' ), 404 ); } } else { throw new WC_API_Exception( 'woocommerce_api_invalid_customer_email', __( 'Invalid customer email', 'woocommerce' ), 404 ); } return $this->get_customer( $customer->ID, $fields ); } catch ( WC_API_Exception $e ) { return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); } }