Automattic\WooCommerce\Internal\RestApi\Routes\V4\Settings\Products\Schema

ProductSettingsSchema::get_field_optionsprivateWC 1.0

Get options for specific field types.

Method of the class: ProductSettingsSchema{}

No Hooks.

Returns

Array. Field options.

Usage

// private - for code of main (parent) class only
$result = $this->get_field_options( $field_id ): array;
$field_id(string) (required)
Field ID.

ProductSettingsSchema::get_field_options() code WC 10.4.3

private function get_field_options( string $field_id ): array {
	switch ( $field_id ) {
		case 'woocommerce_weight_unit':
			return array(
				'kg'  => __( 'kg', 'woocommerce' ),
				'g'   => __( 'g', 'woocommerce' ),
				'lbs' => __( 'lbs', 'woocommerce' ),
				'oz'  => __( 'oz', 'woocommerce' ),
			);

		case 'woocommerce_dimension_unit':
			return array(
				'm'  => __( 'm', 'woocommerce' ),
				'cm' => __( 'cm', 'woocommerce' ),
				'mm' => __( 'mm', 'woocommerce' ),
				'in' => __( 'in', 'woocommerce' ),
				'yd' => __( 'yd', 'woocommerce' ),
			);

		case 'woocommerce_product_type':
			if ( ! function_exists( 'wc_get_product_types' ) ) {
				return array();
			}

			$product_types = wc_get_product_types();
			return is_array( $product_types ) ? $product_types : array();
	}

	return array();
}