WC_REST_Products_V2_Controller::get_attribute_options()protectedWC 1.0

Get attribute options.

Метод класса: WC_REST_Products_V2_Controller{}

Хуков нет.

Возвращает

Массив.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_attribute_options( $product_id, $attribute );
$product_id(int) (обязательный)
Product ID.
$attribute(массив) (обязательный)
Attribute data.

Код WC_REST_Products_V2_Controller::get_attribute_options() WC 8.7.0

protected function get_attribute_options( $product_id, $attribute ) {
	if ( isset( $attribute['is_taxonomy'] ) && $attribute['is_taxonomy'] ) {
		return wc_get_product_terms(
			$product_id,
			$attribute['name'],
			array(
				'fields' => 'names',
			)
		);
	} elseif ( isset( $attribute['value'] ) ) {
		return array_map( 'trim', explode( '|', $attribute['value'] ) );
	}

	return array();
}