diff --git a/includes/cli/class-wc-cli-product.php b/includes/cli/class-wc-cli-product.php index 0b5f61f8b2d..a3f07d4550a 100644 --- a/includes/cli/class-wc-cli-product.php +++ b/includes/cli/class-wc-cli-product.php @@ -207,7 +207,7 @@ class WC_CLI_Product extends WC_CLI_Command { $this->save_product_meta( $id, $data ); // Save variations - if ( isset( $data['type'] ) && 'variable' == $data['type'] && isset( $data['variations'] ) && is_array( $data['variations'] ) ) { + if ( $this->is_variable( $data ) ) { $this->save_variations( $id, $data ); } @@ -657,7 +657,7 @@ class WC_CLI_Product extends WC_CLI_Command { $this->save_product_meta( $id, $data ); // Save variations - if ( isset( $data['type'] ) && 'variable' == $data['type'] && isset( $data['variations'] ) && is_array( $data['variations'] ) ) { + if ( $this->is_variable( $data ) ) { $this->save_variations( $id, $data ); } @@ -2121,4 +2121,21 @@ class WC_CLI_Product extends WC_CLI_Command { // Delete product wp_delete_post( $product_id, true ); } + + /** + * Check if is a variable. + * + * @since 2.6.2 + * @param array $data + * @return bool + */ + private function is_variable( $data ) { + if ( isset( $data['type'] ) && isset( $data['variations'] ) && is_array( $data['variations'] ) ) { + $types = apply_filters( 'woocommerce_cli_get_product_variable_types', array( 'variable' ) ); + + return in_array( $data['type'], $types ); + } + + return false; + } } diff --git a/readme.txt b/readme.txt index 03809060156..356df0914ee 100644 --- a/readme.txt +++ b/readme.txt @@ -174,6 +174,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Fix - Grouped product range display when child is free. * Fix - Remove discount when checking free shipping min amount. * Dev - API - Fixed variable product stock at product level. +* Dev - CLI - Introduces `woocommerce_cli_get_product_variable_types` filter. * Tweak - Made customer pay link display if order needs_payment() rather than checking pending status. * Tweak - Zones - Wording clarifications. * Tweak - Zones - Match zones with postcodes but no country.