WC_REST_Customers_V2_Controller::update_customer_meta_fields
Update customer meta fields.
Method of the class: WC_REST_Customers_V2_Controller{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->update_customer_meta_fields( $customer, $request );
- $customer(WC_Customer) (required)
- Customer data.
- $request(WP_REST_Request) (required)
- Request data.
WC_REST_Customers_V2_Controller::update_customer_meta_fields() WC REST Customers V2 Controller::update customer meta fields code WC 10.3.6
protected function update_customer_meta_fields( $customer, $request ) {
parent::update_customer_meta_fields( $customer, $request );
// Meta data.
if ( isset( $request['meta_data'] ) ) {
if ( is_array( $request['meta_data'] ) ) {
foreach ( $request['meta_data'] as $meta ) {
if ( is_protected_meta( $meta['key'], 'user' ) ) { // bypass internal keys.
continue;
}
$customer->update_meta_data( $meta['key'], $meta['value'], isset( $meta['id'] ) ? $meta['id'] : '' );
}
}
}
}