Skip to content

Introducing support for v3 #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
@@ -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}";
Original file line number Diff line number Diff line change
@@ -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 ********/