Automattic\WooCommerce\StoreApi\Routes\V1

Checkout::update_customer_address_fieldprivateWC 1.0

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() code WC 9.9.4

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 );
	}
}