Skip to content
This repository was archived by the owner on May 28, 2023. It is now read-only.

Commit 1020f4b

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into HEAD
2 parents 7de2877 + 7b29901 commit 1020f4b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

config/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"setConfigurableProductOptions": true,
145145
"sourcePriceIncludesTax": false,
146146
"deprecatedPriceFieldsSupport": true,
147-
"finalPriceIncludesTax": true,
147+
"finalPriceIncludesTax": false,
148148
"userGroupId": null,
149149
"useOnlyDefaultUserGroupId": false
150150
},

src/lib/taxcalc.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ export function updateProductPrices ({ product, rate, sourcePriceInclTax = false
101101

102102
if (product.final_price) {
103103
if (product.final_price < product.price) { // compare the prices with the product final price if provided; final prices is used in case of active catalog promo rules for example
104-
assignPrice({product, target: 'price', price: product.final_price, deprecatedPriceFieldsSupport})
105-
if (product.final_price < product.special_price) { // for VS - special_price is any price lowered than regular price (`price`); in Magento there is a separate mechanism for setting the `special_prices`
106-
assignPrice({product, target: 'price', price: product.special_price, deprecatedPriceFieldsSupport}) // if the `final_price` is lower than the original `special_price` - it means some catalog rules were applied over it
104+
assignPrice({product, target: 'price', ...finalPriceWithTax, deprecatedPriceFieldsSupport})
105+
if (product.special_price && product.final_price < product.special_price) { // for VS - special_price is any price lowered than regular price (`price`); in Magento there is a separate mechanism for setting the `special_prices`
106+
assignPrice({product, target: 'price', ...specialPriceWithTax, deprecatedPriceFieldsSupport}) // if the `final_price` is lower than the original `special_price` - it means some catalog rules were applied over it
107+
assignPrice({product, target: 'special_price', ...finalPriceWithTax, deprecatedPriceFieldsSupport})
108+
} else {
109+
assignPrice({product, target: 'price', ...finalPriceWithTax, deprecatedPriceFieldsSupport})
107110
}
108-
assignPrice({product, target: 'special_price', price: product.final_price, deprecatedPriceFieldsSupport})
109111
}
110112
}
111113

@@ -114,7 +116,7 @@ export function updateProductPrices ({ product, rate, sourcePriceInclTax = false
114116
// out of the dates period
115117
assignPrice({product, target: 'special_price', price: 0, tax: 0, deprecatedPriceFieldsSupport})
116118
} else {
117-
assignPrice({product, target: 'price', price: product.special_price, deprecatedPriceFieldsSupport})
119+
assignPrice({product, target: 'price', ...specialPriceWithTax, deprecatedPriceFieldsSupport})
118120
}
119121
} else {
120122
// the same price as original; it's not a promotion
@@ -168,15 +170,15 @@ export function calculateProductTax ({ product, taxClasses, taxCountry = 'PL', t
168170
if (taxClass) {
169171
for (let rate of taxClass.rates) { // TODO: add check for zip code ranges (!)
170172
if (rate.tax_country_id === taxCountry && (rate.region_name === taxRegion || rate.tax_region_id === 0 || !rate.region_name)) {
171-
updateProductPrices({ product, rate, sourcePriceInclTax, deprecatedPriceFieldsSupport })
173+
updateProductPrices({ product, rate, sourcePriceInclTax, deprecatedPriceFieldsSupport, finalPriceInclTax })
172174
rateFound = true
173175
break
174176
}
175177
}
176178
}
177179
}
178180
if (!rateFound) {
179-
updateProductPrices({ product, rate: {rate: 0}, sourcePriceInclTax, deprecatedPriceFieldsSupport })
181+
updateProductPrices({ product, rate: {rate: 0}, sourcePriceInclTax, deprecatedPriceFieldsSupport, finalPriceInclTax })
180182

181183
product.price_incl_tax = product.price
182184
product.price_tax = 0

0 commit comments

Comments
 (0)