tring */ public function format_additional_field_value( $value, $field ) { return $this->get_field_type( $field )->format_value( $value, $field ); } /** * Applies type-specific arguments to a field before it is rendered with woocommerce_form_field(). * * Used by the server-rendered My Account forms: maps select options, sets checkbox submit values, and * resolves date min/max constraints into input attributes. * * @param array $form_field The woocommerce_form_field() arguments built from the field. * @return array The updated arguments. */ public function prepare_form_field( array $form_field ): array { return $this->get_field_type( $form_field )->prepare_form_field( $form_field ); } /** * Applies type-specific keywords to a field's REST API value schema. * * @param array $field_schema The schema built for the field so far. * @param array $field The field. * @return array The updated schema. */ public function prepare_field_value_schema( array $field_schema, array $field ): array { return $this->get_field_type( $field )->prepare_value_schema( $field_schema, $field ); } /** * Prepares a group name for use. * * @param string $group The group name to prepare. * @return string The prepared group name. */ private function prepare_group_name( $group ) { if ( ! in_array( $group, $this->groups, true ) ) { $group = 'other'; } return $group; } /** * Prepares a location name for use. * * @param string $location The location name to prepare. * @return string The prepared location name. */ private function prepare_location_name( $location ) { if ( 'additional' === $location ) { $location = 'order'; } return $location; } /** * Returns a group meta prefix based on its name. * * @param string $group_name The group name (billing|shipping|other). * @return string The group meta prefix. */ public static function get_group_key( $group_name ) { if ( 'additional' === $group_name ) { wc_deprecated_argument( 'group_name', '8.9.0', 'The "additional" group is deprecated. Use "other" instead.' ); $group_name = 'other'; } if ( 'billing' === $group_name ) { return self::BILLING_FIELDS_PREFIX; } if ( 'shipping' === $group_name ) { return self::SHIPPING_FIELDS_PREFIX; } return self::OTHER_FIELDS_PREFIX; } /** * Returns a group name based on passed group key. * * @param string $group_key The group name (_wc_billing|_wc_shipping|_wc_other). * @return string The group meta prefix. */ public static function get_group_name( $group_key ) { if ( '_wc_additional' === $group_key ) { wc_deprecated_argument( 'group_key', '8.9.0', 'The "_wc_additional" group key is deprecated. Use "_wc_other" instead.' ); $group_key = '_wc_other'; } if ( 0 === \strpos( self::BILLING_FIELDS_PREFIX, $group_key ) ) { return 'billing'; } if ( 0 === \strpos( self::SHIPPING_FIELDS_PREFIX, $group_key ) ) { return 'shipping'; } return 'other'; } }