diff --git a/lib/woocommerce-api/class-wc-api-client.php b/lib/woocommerce-api/class-wc-api-client.php index e27052a..1d7a077 100644 --- a/lib/woocommerce-api/class-wc-api-client.php +++ b/lib/woocommerce-api/class-wc-api-client.php @@ -161,7 +161,7 @@ public function build_api_url() { $path = isset( $url['path'] ) ? rtrim( $url['path'], '/' ) : ''; // add WC API path - $path .= '/wc-api/v2/'; + $path .= '/wc-api/v3/'; // build URL $this->api_url = "{$scheme}://{$host}{$path}"; diff --git a/lib/woocommerce-api/resources/class-wc-api-client-resource-products.php b/lib/woocommerce-api/resources/class-wc-api-client-resource-products.php index 47b2aee..2ee511f 100644 --- a/lib/woocommerce-api/resources/class-wc-api-client-resource-products.php +++ b/lib/woocommerce-api/resources/class-wc-api-client-resource-products.php @@ -45,11 +45,11 @@ public function get( $id = null, $args = array() ) { /** * Get product by SKU * - * GET /products/sku/{sku} + * GET /products/?filter[{sku}] * * Note this will throw an exception if no products are found (404 not found) * - * @since 2.0 + * @since 3.0 * @param string $sku product SKU * @param array $args acceptable product SKU lookup endpoint args, currently only `fields` * @return array|object product! @@ -58,8 +58,7 @@ public function get_by_sku( $sku, $args = array() ) { $this->set_request_args( array( 'method' => 'GET', - 'path' => array( 'sku', urlencode( $sku ) ), - 'params' => $args, + 'params' => array_merge( array( "filter[sku]" => $sku ), $args ) ) ); return $this->do_request(); @@ -195,6 +194,27 @@ public function get_categories( $id = null, $args = array() ) { return $this->do_request(); } + /** + * Retrieve all product orders. + * + * GET /products/{#id}/orders + * + * @since 3.0 + * @param int $id category ID or null to get all product categories + * @param array $args acceptable product categories endpoint args, currently only `fields` + * @return array|object product categories! + */ + public function get_product_orders( $id = null, $args = array() ) { + + $this->set_request_args( array( + 'method' => 'GET', + 'path' => array( $id, 'orders' ), + 'params' => $args, + ) ); + + return $this->do_request(); + } + /** Convenience methods - these do not map directly to an endpoint ********/