Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/woocommerce-api/class-wc-api-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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();
Expand Down Expand Up @@ -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 ********/

Expand Down