Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.
Merged
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
47 changes: 47 additions & 0 deletions api/class-wc-rest-dev-orders-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,51 @@ class WC_REST_Dev_Orders_Controller extends WC_REST_Orders_Controller {
*/
protected $namespace = 'wc/v3';

/**
* Prepare objects query.
*
* @since 3.0.0
* @param WP_REST_Request $request Full details about the request.
* @return array
*/
protected function prepare_objects_query( $request ) {
// This is needed to get around an array to string notice in WC_REST_Orders_Controller::prepare_objects_query
$statuses = $request['status'];
unset( $request['status'] );
$args = parent::prepare_objects_query( $request );

$args['post_status'] = array();
foreach ( $statuses as $status ) {
if ( 'any' === $status ) {
// Set status to "any" and short-circuit out.
$args['post_status'] = 'any';
break;
}
$args['post_status'][] = 'wc-' . $status;
}

return $args;
}

/**
* Get the query params for collections.
*
* @return array
*/
public function get_collection_params() {
$params = parent::get_collection_params();

$params['status'] = array(
'default' => 'any',
'description' => __( 'Limit result set to orders assigned a specific status.', 'woocommerce' ),
'type' => 'array',
'items' => array(
'type' => 'string',
'enum' => array_merge( array( 'any' ), $this->get_order_statuses() ),
),
'validate_callback' => 'rest_validate_request_arg',
);

return $params;
}
}
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: automattic, woothemes
Tags: woocommerce, rest-api, api
Requires at least: 4.6
Tested up to: 4.8
Stable tag: 0.7.1
Stable tag: 0.8.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -25,6 +25,9 @@ This section describes how to install the plugin and get it working.

== Changelog ==

= 0.8.0 =
* Update orders endpoint to accept multiple statuses

= 0.7.1 =
* Fix - add another URI to watch for when disabling sync during API requests

Expand Down
2 changes: 1 addition & 1 deletion wc-api-dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WooCommerce API Dev
* Plugin URI: https://woocommerce.com/
* Description: A feature plugin providing a bleeding edge version of the WooCommerce REST API.
* Version: 0.7.1
* Version: 0.8.0
* Author: Automattic
* Author URI: https://woocommerce.com
* Requires at least: 4.4
Expand Down