Merge pull request #19128 from woocommerce/fix/19123-cli-term-ids

Use correct arg when making rest request in cli
This commit is contained in:
Mike Jolley 2018-03-05 18:39:48 +00:00 committed by GitHub
commit 66ad22e3fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -376,7 +376,7 @@ EOT;
$route = $this->route;
foreach ( $this->get_supported_ids() as $id_name => $id_desc ) {
if ( strpos( $route, '<' . $id_name . '>' ) !== false && ! empty( $args ) ) {
if ( 'id' !== $id_name && strpos( $route, '<' . $id_name . '>' ) !== false && ! empty( $args ) ) {
$route = str_replace( '(?P<' . $id_name . '>[\d]+)', $args[0], $route );
$supported_id_matched = true;
}

View File

@ -97,13 +97,13 @@ 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' ),
'id' => __( 'ID.', 'woocommerce' ),
);
$rest_command->set_supported_ids( $supported_ids );
$positional_args = array_keys( $supported_ids );