Automattic\WooCommerce\StoreApi\Schemas\V1\Agentic
CheckoutSessionSchema::format_buyer
Format buyer information.
Метод класса: CheckoutSessionSchema{}
Хуков нет.
Возвращает
Массив|null. Buyer data or null.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->format_buyer();
Код CheckoutSessionSchema::format_buyer() CheckoutSessionSchema::format buyer WC 11.0.1
protected function format_buyer() {
$customer = WC()->customer;
if ( ! $customer ) {
return null;
}
$first_name = $customer->get_billing_first_name() ? $customer->get_billing_first_name() : $customer->get_shipping_first_name();
$last_name = $customer->get_billing_last_name() ? $customer->get_billing_last_name() : $customer->get_shipping_last_name();
$email = $customer->get_billing_email();
if ( ! $first_name && ! $last_name && ! $email ) {
return null;
}
return [
'first_name' => $first_name ? $first_name : '',
'last_name' => $last_name ? $last_name : '',
'email' => $email ? $email : '',
'phone_number' => $customer->get_billing_phone() ? $customer->get_billing_phone() : '',
];
}