Automattic\WooCommerce\Blocks\Domain\Services
CheckoutFields::set_array_meta
Sets a field value in an array meta, supporting routing things to billing, shipping, or additional fields, based on a prefix for the key.
Method of the class: CheckoutFields{}
Hooks from the method
Returns
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->set_array_meta( $key, $value, $wc_object, $group );
- $key(string) (required)
- The field key.
- $value(mixed) (required)
- The field value.
- $wc_object(WC_Customer|WC_Order) (required)
- The object to set the field value for.
- $group(string) (required)
- The group to set the field value for (shipping|billing|other).
CheckoutFields::set_array_meta() CheckoutFields::set array meta code WC 9.8.5
private function set_array_meta( string $key, $value, WC_Data $wc_object, string $group ) { $meta_key = self::get_group_key( $group ) . $key; /** * Allow reacting for saving an additional field value. * * @param string $key The key of the field being saved. * @param mixed $value The value of the field being saved. * @param string $group The group of this location (shipping|billing|other). * @param WC_Customer|WC_Order $wc_object The object to set the field value for. * * @since 8.9.0 */ do_action( 'woocommerce_set_additional_field_value', $key, $value, $group, $wc_object ); // Convert boolean values to strings because Data Stores will skip false values. if ( is_bool( $value ) ) { $value = $value ? '1' : '0'; } $wc_object->update_meta_data( $meta_key, $value ); }