Automattic\WooCommerce\StoreApi\Routes\V1
ProductsBySlug::get_route_response()
Get a single item.
Method of the class: ProductsBySlug{}
No Hooks.
Return
\WP_REST_Response
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_route_response( $request );
- $request(\WP_REST_Request) (required)
- Request object.
ProductsBySlug::get_route_response() ProductsBySlug::get route response code WC 9.3.3
protected function get_route_response( \WP_REST_Request $request ) { $slug = sanitize_title( $request['slug'] ); $object = $this->get_product_by_slug( $slug ); if ( ! $object ) { $object = $this->get_product_variation_by_slug( $slug ); } if ( ! $object || 0 === $object->get_id() ) { throw new RouteException( 'woocommerce_rest_product_invalid_slug', __( 'Invalid product slug.', 'woocommerce' ), 404 ); } return rest_ensure_response( $this->schema->get_item_response( $object ) ); }