12
12
use Magento \Sales \Model \Order ;
13
13
14
14
/**
15
+ * Tax totals modification block.
16
+ *
15
17
* @api
16
18
* @since 100.0.2
17
19
*/
@@ -103,6 +105,10 @@ public function initTotals()
103
105
protected function _addTax ($ after = 'discount ' )
104
106
{
105
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
+ }
106
112
$ this ->getParentBlock ()->addTotal ($ taxTotal , $ after );
107
113
return $ this ;
108
114
}
@@ -118,6 +124,8 @@ public function getStore()
118
124
}
119
125
120
126
/**
127
+ * Initialization grand total.
128
+ *
121
129
* @return $this
122
130
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
123
131
*/
@@ -199,6 +207,8 @@ protected function _initSubtotal()
199
207
}
200
208
201
209
/**
210
+ * Init shipping.
211
+ *
202
212
* @return $this
203
213
*/
204
214
protected function _initShipping ()
@@ -260,13 +270,19 @@ protected function _initShipping()
260
270
}
261
271
262
272
/**
273
+ * Init discount.
274
+ *
275
+ * phpcs:disable Magento2.CodeAnalysis.EmptyBlock
276
+ *
263
277
* @return void
264
278
*/
265
279
protected function _initDiscount ()
266
280
{
267
281
}
268
-
282
+ //phpcs:enable
269
283
/**
284
+ * Init grand total.
285
+ *
270
286
* @return $this
271
287
*/
272
288
protected function _initGrandTotal ()
@@ -304,13 +320,15 @@ protected function _initGrandTotal()
304
320
]
305
321
);
306
322
$ parent ->addTotal ($ totalExcl , 'grand_total ' );
307
- $ this ->_addTax ('grand_total ' );
308
323
$ parent ->addTotal ($ totalIncl , 'tax ' );
324
+ $ this ->_addTax ('grand_total ' );
309
325
}
310
326
return $ this ;
311
327
}
312
328
313
329
/**
330
+ * Return order.
331
+ *
314
332
* @return Order
315
333
*/
316
334
public function getOrder ()
@@ -319,6 +337,8 @@ public function getOrder()
319
337
}
320
338
321
339
/**
340
+ * Return label properties.
341
+ *
322
342
* @return array
323
343
*/
324
344
public function getLabelProperties ()
@@ -327,6 +347,8 @@ public function getLabelProperties()
327
347
}
328
348
329
349
/**
350
+ * Retuen value properties.
351
+ *
330
352
* @return array
331
353
*/
332
354
public function getValueProperties ()
0 commit comments