Merge pull request #14787 from woocommerce/fix/14750
Fix zone routes in CLI
This commit is contained in:
commit
8885c66d8c
|
@ -26,7 +26,7 @@ class WC_REST_Shipping_Zone_Locations_Controller extends WC_REST_Shipping_Zones_
|
|||
* Register the routes for Shipping Zone Locations.
|
||||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d-]+)/locations', array(
|
||||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)/locations', array(
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'description' => __( 'Unique ID for the resource.', 'woocommerce' ),
|
||||
|
|
|
@ -26,7 +26,7 @@ class WC_REST_Shipping_Zone_Methods_Controller extends WC_REST_Shipping_Zones_Co
|
|||
* Register the routes for Shipping Zone Methods.
|
||||
*/
|
||||
public function register_routes() {
|
||||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d-]+)/methods', array(
|
||||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d]+)/methods', array(
|
||||
'args' => array(
|
||||
'zone_id' => array(
|
||||
'description' => __( 'Unique ID for the zone.', 'woocommerce' ),
|
||||
|
@ -53,7 +53,7 @@ class WC_REST_Shipping_Zone_Methods_Controller extends WC_REST_Shipping_Zones_Co
|
|||
'schema' => array( $this, 'get_public_item_schema' ),
|
||||
) );
|
||||
|
||||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d-]+)/methods/(?P<instance_id>[\d-]+)', array(
|
||||
register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<zone_id>[\d]+)/methods/(?P<instance_id>[\d-]+)', array(
|
||||
'args' => array(
|
||||
'zone_id' => array(
|
||||
'description' => __( 'Unique ID for the zone.', 'woocommerce' ),
|
||||
|
|
|
@ -92,14 +92,16 @@ class WC_CLI_Runner {
|
|||
// Define IDs that we are looking for in the routes (in addition to id)
|
||||
// so that we can pass it to the rest command, and use it here to generate documentation.
|
||||
$supported_ids = array(
|
||||
'id' => __( 'ID.', 'woocommerce' ),
|
||||
'product_id' => __( 'Product ID.', 'woocommerce' ),
|
||||
'customer_id' => __( 'Customer ID.', 'woocommerce' ),
|
||||
'order_id' => __( 'Order ID.', 'woocommerce' ),
|
||||
'refund_id' => __( 'Refund ID.', 'woocommerce' ),
|
||||
'attribute_id' => __( 'Attribute ID.', 'woocommerce' ),
|
||||
'zone_id' => __( 'Zone ID.', 'woocommerce' ),
|
||||
);
|
||||
$rest_command->set_supported_ids( $supported_ids );
|
||||
$positional_args = array_merge( array( 'id' ), array_keys( $supported_ids ) );
|
||||
$positional_args = array_keys( $supported_ids );
|
||||
|
||||
$parent = "wc {$route_data['schema']['title']}";
|
||||
$supported_commands = array();
|
||||
|
|
|
@ -64,9 +64,9 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
|
|||
$routes = $this->server->get_routes();
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<id>[\d-]+)', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<id>[\d-]+)/locations', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<zone_id>[\d-]+)/methods', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<zone_id>[\d-]+)/methods/(?P<instance_id>[\d-]+)', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<id>[\d]+)/locations', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<zone_id>[\d]+)/methods', $routes );
|
||||
$this->assertArrayHasKey( '/wc/v2/shipping/zones/(?P<zone_id>[\d]+)/methods/(?P<instance_id>[\d-]+)', $routes );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue