@@ -236,7 +236,8 @@ function _buildVariantImagesAction(
236236function _buildVariantPricesAction (
237237 diffedPrices ,
238238 oldVariant = { } ,
239- newVariant = { }
239+ newVariant = { } ,
240+ enableDiscounted = false
240241) {
241242 const addPriceActions = [ ]
242243 const changePriceActions = [ ]
@@ -260,7 +261,7 @@ function _buildVariantPricesAction(
260261 // Remove read-only fields
261262 const patchedPrice = price . map ( ( p ) => {
262263 const shallowClone = { ...p }
263- delete shallowClone . discounted
264+ if ( enableDiscounted !== true ) delete shallowClone . discounted
264265 return shallowClone
265266 } )
266267
@@ -273,11 +274,11 @@ function _buildVariantPricesAction(
273274 // Remove the discounted field and make sure that the price
274275 // still has other values, otherwise simply return
275276 const filteredPrice = { ...price }
276- delete filteredPrice . discounted
277+ if ( enableDiscounted !== true ) delete filteredPrice . discounted
277278 if ( Object . keys ( filteredPrice ) . length ) {
278279 // At this point price should have changed, simply pick the new one
279280 const newPrice = { ...newObj }
280- delete newPrice . discounted
281+ if ( enableDiscounted !== true ) delete newPrice . discounted
281282
282283 changePriceActions . push ( {
283284 action : 'changePrice' ,
@@ -607,7 +608,13 @@ export function actionsMapImages(diff, oldObj, newObj, variantHashMap) {
607608 return actions
608609}
609610
610- export function actionsMapPrices ( diff , oldObj , newObj , variantHashMap ) {
611+ export function actionsMapPrices (
612+ diff ,
613+ oldObj ,
614+ newObj ,
615+ variantHashMap ,
616+ enableDiscounted
617+ ) {
611618 let addPriceActions = [ ]
612619 let changePriceActions = [ ]
613620 let removePriceActions = [ ]
@@ -626,7 +633,8 @@ export function actionsMapPrices(diff, oldObj, newObj, variantHashMap) {
626633 const [ a , c , r ] = _buildVariantPricesAction (
627634 variant . prices ,
628635 oldVariant ,
629- newVariant
636+ newVariant ,
637+ enableDiscounted
630638 )
631639
632640 addPriceActions = addPriceActions . concat ( a )
0 commit comments