WC_API_Products::get_attribute_options()protectedWC 1.0

Get attribute options.

Method of the class: WC_API_Products{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_attribute_options( $product_id, $attribute );
$product_id(int) (required)
-
$attribute(array) (required)
-

WC_API_Products::get_attribute_options() code WC 8.6.1

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();
}