Automattic\WooCommerce\Admin\API
ProductAttributes::get_item_by_slug()
Get a single attribute by it's slug.
Метод класса: ProductAttributes{}
Хуков нет.
Возвращает
WP_REST_Response
.
Использование
$ProductAttributes = new ProductAttributes(); $ProductAttributes->get_item_by_slug( $request );
- $request(WP_REST_Request) (обязательный)
- The API request.
Код ProductAttributes::get_item_by_slug() ProductAttributes::get item by slug WC 9.8.1
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 ); }