@@ -86,11 +86,7 @@ public function initTotals()
86
86
$ allowTax = $ this ->_source ->getTaxAmount () > 0 || $ this ->_config ->displaySalesZeroTax ($ store );
87
87
$ grandTotal = (double )$ this ->_source ->getGrandTotal ();
88
88
if (!$ grandTotal || $ allowTax && !$ this ->_config ->displaySalesTaxWithGrandTotal ($ store )) {
89
- $ taxTotal = new \Magento \Framework \DataObject (['code ' => 'tax ' , 'block_name ' => $ this ->getNameInLayout ()]);
90
- $ totals = $ this ->getParentBlock ()->getTotals ();
91
- if ($ totals ['grand_total ' ]) {
92
- $ this ->getParentBlock ()->addTotalBefore ($ taxTotal , 'grand_total ' );
93
- }
89
+ $ this ->_addTax ();
94
90
}
95
91
96
92
$ this ->_initSubtotal ();
@@ -109,6 +105,10 @@ public function initTotals()
109
105
protected function _addTax ($ after = 'discount ' )
110
106
{
111
107
$ taxTotal = new \Magento \Framework \DataObject (['code ' => 'tax ' , 'block_name ' => $ this ->getNameInLayout ()]);
108
+ $ totals = $ this ->getParentBlock ()->getTotals ();
109
+ if ($ totals ['grand_total ' ]) {
110
+ $ this ->getParentBlock ()->addTotalBefore ($ taxTotal , 'grand_total ' );
111
+ }
112
112
$ this ->getParentBlock ()->addTotal ($ taxTotal , $ after );
113
113
return $ this ;
114
114
}
@@ -273,12 +273,13 @@ protected function _initShipping()
273
273
* Init discount.
274
274
*
275
275
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
276
+ *
276
277
* @return void
277
278
*/
278
279
protected function _initDiscount ()
279
280
{
280
281
}
281
-
282
+ //phpcs:enable
282
283
/**
283
284
* Init grand total.
284
285
*
@@ -319,8 +320,8 @@ protected function _initGrandTotal()
319
320
]
320
321
);
321
322
$ parent ->addTotal ($ totalExcl , 'grand_total ' );
322
- $ this ->_addTax ('grand_total ' );
323
323
$ parent ->addTotal ($ totalIncl , 'tax ' );
324
+ $ this ->_addTax ('grand_total ' );
324
325
}
325
326
return $ this ;
326
327
}
0 commit comments