Automattic\WooCommerce\StoreApi\Routes\V1
Checkout::update_customer_address_field
Updates a customer address field.
Method of the class: Checkout{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->update_customer_address_field( $customer, $key, $value, $address_type );
- $customer(WC_Customer) (required)
- The customer to update.
- $key(string) (required)
- The key of the field to update.
- $value(mixed) (required)
- The value to update the field to.
- $address_type(string) (required)
- The type of address to update (billing|shipping).
Checkout::update_customer_address_field() Checkout::update customer address field code WC 11.0.0
private function update_customer_address_field( $customer, $key, $value, $address_type ) {
$callback = "set_{$address_type}_{$key}";
if ( is_callable( [ $customer, $callback ] ) ) {
$customer->$callback( $value );
return;
}
if ( $this->additional_fields_controller->is_field( $key ) ) {
$this->additional_fields_controller->persist_field_for_customer( $key, $value, $customer, $address_type );
}
}