diff --git a/includes/api/legacy/v2/class-wc-api-products.php b/includes/api/legacy/v2/class-wc-api-products.php index 0867420a62d..72b463877e9 100644 --- a/includes/api/legacy/v2/class-wc-api-products.php +++ b/includes/api/legacy/v2/class-wc-api-products.php @@ -1034,7 +1034,7 @@ class WC_API_Products extends WC_API_Resource { $product->set_attributes( $attributes ); } - // Sales and prices + // Sales and prices. if ( in_array( $product->get_type(), array( 'variable', 'grouped' ) ) ) { // Variable and grouped products have no prices. @@ -1046,23 +1046,18 @@ class WC_API_Products extends WC_API_Resource { } else { - // Regular Price + // Regular Price. if ( isset( $data['regular_price'] ) ) { $regular_price = ( '' === $data['regular_price'] ) ? '' : $data['regular_price']; - } else { - $regular_price = $product->get_regular_price(); + $product->set_regular_price( $regular_price ); } - // Sale Price + // Sale Price. if ( isset( $data['sale_price'] ) ) { $sale_price = ( '' === $data['sale_price'] ) ? '' : $data['sale_price']; - } else { - $sale_price = $product->get_sale_price(); + $product->set_sale_price( $sale_price ); } - $product->set_regular_price( $regular_price ); - $product->set_sale_price( $sale_price ); - if ( isset( $data['sale_price_dates_from'] ) ) { $date_from = $data['sale_price_dates_from']; } else { diff --git a/includes/api/legacy/v3/class-wc-api-products.php b/includes/api/legacy/v3/class-wc-api-products.php index 26be8d70148..dbfc36ef6b3 100644 --- a/includes/api/legacy/v3/class-wc-api-products.php +++ b/includes/api/legacy/v3/class-wc-api-products.php @@ -1536,23 +1536,18 @@ class WC_API_Products extends WC_API_Resource { } else { - // Regular Price + // Regular Price. if ( isset( $data['regular_price'] ) ) { $regular_price = ( '' === $data['regular_price'] ) ? '' : $data['regular_price']; - } else { - $regular_price = $product->get_regular_price(); + $product->set_regular_price( $regular_price ); } - // Sale Price + // Sale Price. if ( isset( $data['sale_price'] ) ) { $sale_price = ( '' === $data['sale_price'] ) ? '' : $data['sale_price']; - } else { - $sale_price = $product->get_sale_price(); + $product->set_sale_price( $sale_price ); } - $product->set_regular_price( $regular_price ); - $product->set_sale_price( $sale_price ); - if ( isset( $data['sale_price_dates_from'] ) ) { $date_from = $data['sale_price_dates_from']; } else {