WordPress at Your Fingertips
function is not described

WC_Checkout::set_customer_address_fields() protected WC 3.0.7

Set address field for customer.

{} It's a method of the class: WC_Checkout{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->set_customer_address_fields( $field, $key, $data );
$field(string) (required)
String to update.
$key(string) (required)
Field key.
$data(array) (required)
Array of data to get the value from.

Changelog

Since 3.0.7 Introduced.

Code of WC_Checkout::set_customer_address_fields() WC 5.9.0

protected function set_customer_address_fields( $field, $key, $data ) {
	$billing_value  = null;
	$shipping_value = null;

	if ( isset( $data[ "billing_{$field}" ] ) && is_callable( array( WC()->customer, "set_billing_{$field}" ) ) ) {
		$billing_value  = $data[ "billing_{$field}" ];
		$shipping_value = $data[ "billing_{$field}" ];
	}

	if ( isset( $data[ "shipping_{$field}" ] ) && is_callable( array( WC()->customer, "set_shipping_{$field}" ) ) ) {
		$shipping_value = $data[ "shipping_{$field}" ];
	}

	if ( ! is_null( $billing_value ) && is_callable( array( WC()->customer, "set_billing_{$field}" ) ) ) {
		WC()->customer->{"set_billing_{$field}"}( $billing_value );
	}

	if ( ! is_null( $shipping_value ) && is_callable( array( WC()->customer, "set_shipping_{$field}" ) ) ) {
		WC()->customer->{"set_shipping_{$field}"}( $shipping_value );
	}
}