Use edit context when updating prices in the API

Fixes #17125
This commit is contained in:
Mike Jolley 2017-10-13 16:37:38 +01:00
parent c1b83df5f6
commit 840da4f0c8
2 changed files with 6 additions and 4 deletions

View File

@ -1076,10 +1076,11 @@ class WC_API_Products extends WC_API_Resource {
$product->set_date_on_sale_to( $date_to ); $product->set_date_on_sale_to( $date_to );
$product->set_date_on_sale_from( $date_from ); $product->set_date_on_sale_from( $date_from );
if ( $product->is_on_sale() ) { if ( $product->is_on_sale() ) {
$product->set_price( $product->get_sale_price() ); $product->set_price( $product->get_sale_price( 'edit' ) );
} else { } else {
$product->set_price( $product->get_regular_price() ); $product->set_price( $product->get_regular_price( 'edit' ) );
} }
} }

View File

@ -1566,10 +1566,11 @@ class WC_API_Products extends WC_API_Resource {
$product->set_date_on_sale_to( $date_to ); $product->set_date_on_sale_to( $date_to );
$product->set_date_on_sale_from( $date_from ); $product->set_date_on_sale_from( $date_from );
if ( $product->is_on_sale() ) { if ( $product->is_on_sale() ) {
$product->set_price( $product->get_sale_price() ); $product->set_price( $product->get_sale_price( 'edit' ) );
} else { } else {
$product->set_price( $product->get_regular_price() ); $product->set_price( $product->get_regular_price( 'edit' ) );
} }
} }