Merge pull request #10949 from kravco/fix-cli-product

[API] Fixed product create not honoring --porcelain argument
This commit is contained in:
Claudio Sanches 2016-05-20 02:08:43 -03:00
commit 36b5df4a2b
1 changed files with 8 additions and 1 deletions

View File

@ -144,6 +144,9 @@ class WC_CLI_Product extends WC_CLI_Command {
$id = 0; $id = 0;
try { try {
$porcelain = isset( $assoc_args['porcelain'] );
unset( $assoc_args['porcelain'] );
$data = apply_filters( 'woocommerce_cli_create_product_data', $this->unflatten_array( $assoc_args ) ); $data = apply_filters( 'woocommerce_cli_create_product_data', $this->unflatten_array( $assoc_args ) );
// Check if product title is specified // Check if product title is specified
@ -213,7 +216,11 @@ class WC_CLI_Product extends WC_CLI_Command {
// Clear cache/transients // Clear cache/transients
wc_delete_product_transients( $id ); wc_delete_product_transients( $id );
if ( $porcelain ) {
WP_CLI::line( $id );
} else {
WP_CLI::success( "Created product $id." ); WP_CLI::success( "Created product $id." );
}
} catch ( WC_CLI_Exception $e ) { } catch ( WC_CLI_Exception $e ) {
// Remove the product when fails // Remove the product when fails
$this->clear_product( $id ); $this->clear_product( $id );