Automattic\WooCommerce\Admin\API

ProductAttributes::get_item_by_slug()publicWC 1.0

Get a single attribute by it's slug.

Method of the class: ProductAttributes{}

No Hooks.

Return

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() code WC 8.7.0

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 );
}