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.
Метод класса: CheckoutFields{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
// private - только в коде основоного (родительского) класса $result = $this->set_array_meta( $key, $value, $wc_object, $group );
- $key(строка) (обязательный)
- The field key.
- $value(разное) (обязательный)
- The field value.
- $wc_object(WC_Customer|WC_Order) (обязательный)
- The object to set the field value for.
- $group(строка) (обязательный)
- The group to set the field value for (shipping|billing|other).
Код CheckoutFields::set_array_meta() CheckoutFields::set array meta WC 9.8.1
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 ); }