From 840da4f0c8b75408bbcb522b6aae2db04e6a9e8b Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 13 Oct 2017 16:37:38 +0100 Subject: [PATCH] Use edit context when updating prices in the API Fixes #17125 --- includes/api/legacy/v2/class-wc-api-products.php | 5 +++-- includes/api/legacy/v3/class-wc-api-products.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/api/legacy/v2/class-wc-api-products.php b/includes/api/legacy/v2/class-wc-api-products.php index 72b463877e9..661e4219678 100644 --- a/includes/api/legacy/v2/class-wc-api-products.php +++ b/includes/api/legacy/v2/class-wc-api-products.php @@ -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_from( $date_from ); + if ( $product->is_on_sale() ) { - $product->set_price( $product->get_sale_price() ); + $product->set_price( $product->get_sale_price( 'edit' ) ); } else { - $product->set_price( $product->get_regular_price() ); + $product->set_price( $product->get_regular_price( 'edit' ) ); } } diff --git a/includes/api/legacy/v3/class-wc-api-products.php b/includes/api/legacy/v3/class-wc-api-products.php index dbfc36ef6b3..e6e64d47ea0 100644 --- a/includes/api/legacy/v3/class-wc-api-products.php +++ b/includes/api/legacy/v3/class-wc-api-products.php @@ -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_from( $date_from ); + if ( $product->is_on_sale() ) { - $product->set_price( $product->get_sale_price() ); + $product->set_price( $product->get_sale_price( 'edit' ) ); } else { - $product->set_price( $product->get_regular_price() ); + $product->set_price( $product->get_regular_price( 'edit' ) ); } }