File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -40,20 +40,26 @@ public function __construct(ProductCollectionItem $item, IsotopeProductCollectio
40
40
$ taxFreePrice = (int ) round ($ item ->getTaxFreePrice () * 100 );
41
41
$ price = (int ) round ($ item ->getPrice () * 100 );
42
42
43
- $ this ->total_tax_amount = $ price - $ taxFreePrice ;
43
+ if (null !== $ taxRate ) {
44
+ if ($ price > $ taxFreePrice ) {
45
+ // Taxes are included in the price
46
+ $ this ->total_tax_amount = (int ) round ($ this ->total_amount - $ this ->total_amount * 10000 / (10000 + $ taxRate ));
47
+ } else {
48
+ // Taxes are added as surcharge
49
+ $ taxRate = 0 ;
50
+ }
51
+ }
44
52
45
53
// No distinct tax rate was found, maybe multiple taxes apply, simply calculate the tax_rate
46
54
if (null === $ taxRate && $ taxFreePrice > 0 ) {
47
55
$ taxRate = ($ price - $ taxFreePrice ) / $ taxFreePrice ;
48
56
$ taxRate = (int ) round ($ taxRate * 100 );
49
- }
50
57
51
- $ this ->tax_rate = $ taxRate ?? 0 ;
52
-
53
- if (0 !== $ this ->tax_rate ) {
54
- $ this ->total_tax_amount = (int ) round ($ this ->total_amount - $ this ->total_amount * 10000 / (10000 + $ this ->tax_rate ));
58
+ $ this ->total_tax_amount = $ price - $ taxFreePrice ;
55
59
}
56
60
61
+ $ this ->tax_rate = $ taxRate ;
62
+
57
63
$ this ->addType ($ item );
58
64
$ this ->addProductUrl ($ item );
59
65
$ this ->addImageUrl ($ item );
You can’t perform that action at this time.
0 commit comments