[CLI] Allow filter the product variable types, closes #11240

This commit is contained in:
Claudio Sanches 2016-06-24 12:36:34 -03:00
parent fd5d1e2085
commit 34a28d6841
2 changed files with 20 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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.