Merge pull request #16651 from woocommerce/fix/16650

Update price if product type changes
This commit is contained in:
Claudiu Lodromanean 2017-08-30 08:46:16 -07:00 committed by GitHub
commit b6cf7a025b
1 changed files with 2 additions and 1 deletions

View File

@ -553,7 +553,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$product->set_sale_price( '' );
}
}
if ( in_array( 'date_on_sale_from', $this->updated_props, true ) || in_array( 'date_on_sale_to', $this->updated_props, true ) || in_array( 'regular_price', $this->updated_props, true ) || in_array( 'sale_price', $this->updated_props, true ) ) {
if ( in_array( 'date_on_sale_from', $this->updated_props, true ) || in_array( 'date_on_sale_to', $this->updated_props, true ) || in_array( 'regular_price', $this->updated_props, true ) || in_array( 'sale_price', $this->updated_props, true ) || in_array( 'product_type', $this->updated_props, true ) ) {
if ( $product->is_on_sale( 'edit' ) ) {
update_post_meta( $product->get_id(), '_price', $product->get_sale_price( 'edit' ) );
$product->set_price( $product->get_sale_price( 'edit' ) );
@ -741,6 +741,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
// Action for the transition.
if ( $old_type !== $new_type ) {
$this->updated_props[] = 'product_type';
do_action( 'woocommerce_product_type_changed', $product, $old_type, $new_type );
}
}