Automattic\WooCommerce\Blocks\StoreApi\Schemas
BillingAddressSchema::get_item_response() public WC 1.0
Convert a term object into an object suitable for the response.
{} Это метод класса: BillingAddressSchema{}
Хуков нет.
Возвращает
stdClass
. Null. Ничего.
Использование
$BillingAddressSchema = new BillingAddressSchema(); $BillingAddressSchema->get_item_response( $address );
- $address(\WC_Order/\WC_Customer) (обязательный)
- An object with billing address.
Код BillingAddressSchema::get_item_response() BillingAddressSchema::get item response WC 5.2.0
public function get_item_response( $address ) {
if ( ( $address instanceof \WC_Customer || $address instanceof \WC_Order ) ) {
return (object) $this->prepare_html_response(
[
'first_name' => $address->get_billing_first_name(),
'last_name' => $address->get_billing_last_name(),
'company' => $address->get_billing_company(),
'address_1' => $address->get_billing_address_1(),
'address_2' => $address->get_billing_address_2(),
'city' => $address->get_billing_city(),
'state' => $address->get_billing_state(),
'postcode' => $address->get_billing_postcode(),
'country' => $address->get_billing_country(),
'email' => $address->get_billing_email(),
'phone' => $address->get_billing_phone(),
]
);
}
throw new RouteException(
'invalid_object_type',
sprintf(
/* translators: Placeholders are class and method names */
__( '%1$s requires an instance of %2$s or %3$s for the address', 'woocommerce' ),
'BillingAddressSchema::get_item_response',
'WC_Customer',
'WC_Order'
),
500
);
}