WC_REST_Product_Attributes_V1_Controller::get_attribute() protected WC 1.0
Get attribute data.
{} It's a 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.
Code of WC_REST_Product_Attributes_V1_Controller::get_attribute() WC REST Product Attributes V1 Controller::get attribute WC 5.0.0
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;
}