Automattic\WooCommerce\StoreApi\Routes\V1

ShopperListsBySlug::get_route_responseprotectedWC 1.0

Return the list metadata for the requested slug.

Method of the class: ShopperListsBySlug{}

No Hooks.

Returns

\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.

ShopperListsBySlug::get_route_response() code WC 10.9.4

protected function get_route_response( \WP_REST_Request $request ) {
	$list = ShopperList::get_by_slug( (string) $request['slug'] );

	if ( ! $list ) {
		throw new RouteException( 'woocommerce_rest_shopper_list_not_found', esc_html__( 'Your saved list isn\'t available right now.', 'woocommerce' ), 404 );
	}

	return rest_ensure_response( $this->prepare_item_for_response( $list, $request ) );
}