WC_REST_Product_Attributes_V1_Controller::get_items()
Get all attributes.
Method of the class: WC_REST_Product_Attributes_V1_Controller{}
No Hooks.
Return
Array
.
Usage
$WC_REST_Product_Attributes_V1_Controller = new WC_REST_Product_Attributes_V1_Controller(); $WC_REST_Product_Attributes_V1_Controller->get_items( $request );
- $request(WP_REST_Request) (required)
- The request to get the attributes from.
WC_REST_Product_Attributes_V1_Controller::get_items() WC REST Product Attributes V1 Controller::get items code WC 9.8.1
public function get_items( $request ) { $attributes = wc_get_attribute_taxonomies(); $data = array(); foreach ( $attributes as $attribute_obj ) { $attribute = $this->prepare_item_for_response( $attribute_obj, $request ); $attribute = $this->prepare_response_for_collection( $attribute ); $data[] = $attribute; } $response = rest_ensure_response( $data ); // This API call always returns all product attributes due to retrieval from the object cache. $response->header( 'X-WP-Total', count( $data ) ); $response->header( 'X-WP-TotalPages', 1 ); return $response; }