Automattic\WooCommerce\Admin\API
ProductAttributes::get_item_by_slug
Get a single attribute by it's slug.
Method of the class: ProductAttributes{}
No Hooks.
Returns
WP_REST_Response.
Usage
$ProductAttributes = new ProductAttributes(); $ProductAttributes->get_item_by_slug( $request );
- $request(WP_REST_Request) (required)
- The API request.
ProductAttributes::get_item_by_slug() ProductAttributes::get item by slug code WC 10.4.3
public function get_item_by_slug( $request ) {
if ( empty( $request['slug'] ) ) {
return array();
}
$attributes = $this->get_custom_attribute_by_slug( $request['slug'] );
if ( is_wp_error( $attributes ) ) {
return $attributes;
}
$response_items = $this->format_custom_attribute_items_for_response( $attributes );
return reset( $response_items );
}