Automattic\WooCommerce\StoreApi\Schemas\V1\Agentic
CheckoutSessionSchema::build_address_array
Build address array from components.
Method of the class: CheckoutSessionSchema{}
No Hooks.
Returns
Array. Address array.
Usage
// protected - for code of main (parent) or child class $result = $this->build_address_array( $first_name, $last_name, $address_1, $address_2, $city, $state, $country, $postcode );
- $first_name(string) (required)
- First name.
- $last_name(string) (required)
- Last name.
- $address_1(string) (required)
- Address line 1.
- $address_2(string) (required)
- Address line 2.
- $city(string) (required)
- City.
- $state(string) (required)
- State.
- $country(string) (required)
- Country.
- $postcode(string) (required)
- Postcode.
CheckoutSessionSchema::build_address_array() CheckoutSessionSchema::build address array code WC 10.8.1
protected function build_address_array( $first_name, $last_name, $address_1, $address_2, $city, $state, $country, $postcode ) {
$name = trim( $first_name . ' ' . $last_name );
return [
'name' => $name ? $name : 'Customer',
'line_one' => $address_1,
'line_two' => $address_2 ? $address_2 : '',
'city' => $city,
'state' => $state,
'country' => $country,
'postal_code' => $postcode,
];
}