[CLI] Allow filter the product variable types, closes #11240
This commit is contained in:
parent
fd5d1e2085
commit
34a28d6841
|
@ -207,7 +207,7 @@ class WC_CLI_Product extends WC_CLI_Command {
|
||||||
$this->save_product_meta( $id, $data );
|
$this->save_product_meta( $id, $data );
|
||||||
|
|
||||||
// Save variations
|
// 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 );
|
$this->save_variations( $id, $data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,7 +657,7 @@ class WC_CLI_Product extends WC_CLI_Command {
|
||||||
$this->save_product_meta( $id, $data );
|
$this->save_product_meta( $id, $data );
|
||||||
|
|
||||||
// Save variations
|
// 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 );
|
$this->save_variations( $id, $data );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2121,4 +2121,21 @@ class WC_CLI_Product extends WC_CLI_Command {
|
||||||
// Delete product
|
// Delete product
|
||||||
wp_delete_post( $product_id, true );
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 - Grouped product range display when child is free.
|
||||||
* Fix - Remove discount when checking free shipping min amount.
|
* Fix - Remove discount when checking free shipping min amount.
|
||||||
* Dev - API - Fixed variable product stock at product level.
|
* 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 - Made customer pay link display if order needs_payment() rather than checking pending status.
|
||||||
* Tweak - Zones - Wording clarifications.
|
* Tweak - Zones - Wording clarifications.
|
||||||
* Tweak - Zones - Match zones with postcodes but no country.
|
* Tweak - Zones - Match zones with postcodes but no country.
|
||||||
|
|
Loading…
Reference in New Issue