WC_REST_Products_V1_Controller::get_attribute_options() protected WC 1.0
Get attribute options.
{} It's a method of the class: WC_REST_Products_V1_Controller{}
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)
- Product ID.
- $attribute(array) (required)
- Attribute data.
Code of WC_REST_Products_V1_Controller::get_attribute_options() WC REST Products V1 Controller::get attribute options WC 5.0.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();
}