WC_API_Products::get_attribute_options( int $product_id, array $attribute )

Get attribute options.


Description Description


Parameters Parameters

$product_id

(Required)

$attribute

(Required)


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/legacy/api/v2/class-wc-api-products.php

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


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.