WC_REST_Product_Attributes_V1_Controller::get_attribute()
Get attribute data.
Method of the class: WC_REST_Product_Attributes_V1_Controller{}
No Hooks.
Return
stdClass|WP_Error
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_attribute( $id );
- $id(int) (required)
- Attribute ID.
WC_REST_Product_Attributes_V1_Controller::get_attribute() WC REST Product Attributes V1 Controller::get attribute code WC 9.8.1
protected function get_attribute( $id ) { global $wpdb; $attribute = $wpdb->get_row( $wpdb->prepare( " SELECT * FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_id = %d ", $id ) ); if ( is_wp_error( $attribute ) || is_null( $attribute ) ) { return new WP_Error( 'woocommerce_rest_attribute_invalid', __( 'Resource does not exist.', 'woocommerce' ), array( 'status' => 404 ) ); } return $attribute; }