49 parent::__construct($context,
$data);
61 if (method_exists($child,
'initTotals') && is_callable([$child,
'initTotals'])) {
65 return parent::_beforeToHtml();
75 if ($this->_order ===
null) {
77 $this->_order = $this->
_getData(
'order');
78 }
elseif ($this->_coreRegistry->registry(
'current_order')) {
79 $this->_order = $this->_coreRegistry->registry(
'current_order');
117 $this->_totals[
'subtotal'] = new \Magento\Framework\DataObject(
118 [
'code' =>
'subtotal',
'value' =>
$source->getSubtotal(),
'label' =>
__(
'Subtotal')]
124 if (!
$source->getIsVirtual() && ((double)
$source->getShippingAmount() ||
$source->getShippingDescription())) {
125 $this->_totals[
'shipping'] = new \Magento\Framework\DataObject(
127 'code' =>
'shipping',
128 'field' =>
'shipping_amount',
129 'value' => $this->
getSource()->getShippingAmount(),
130 'label' =>
__(
'Shipping & Handling'),
138 if ((
double)$this->
getSource()->getDiscountAmount() != 0) {
139 if ($this->
getSource()->getDiscountDescription()) {
140 $discountLabel =
__(
'Discount (%1)',
$source->getDiscountDescription());
142 $discountLabel =
__(
'Discount');
144 $this->_totals[
'discount'] = new \Magento\Framework\DataObject(
146 'code' =>
'discount',
147 'field' =>
'discount_amount',
148 'value' =>
$source->getDiscountAmount(),
149 'label' => $discountLabel,
154 $this->_totals[
'grand_total'] = new \Magento\Framework\DataObject(
156 'code' =>
'grand_total',
157 'field' =>
'grand_total',
159 'value' =>
$source->getGrandTotal(),
160 'label' =>
__(
'Grand Total'),
167 if ($this->
getOrder()->isCurrencyDifferent()) {
168 $this->_totals[
'base_grandtotal'] = new \Magento\Framework\DataObject(
170 'code' =>
'base_grandtotal',
171 'value' => $this->
getOrder()->formatBasePrice(
$source->getBaseGrandTotal()),
172 'label' =>
__(
'Grand Total to be Charged'),
173 'is_formated' =>
true,
189 if ($after !==
null && $after !=
'last' && $after !=
'first') {
194 if (
$code == $after) {
196 $totals[$total->getCode()] = $total;
201 $totals[$total->getCode()] = $total;
202 $totals[$last->getCode()] = $last;
205 }
elseif ($after ==
'last') {
206 $this->_totals[$total->getCode()] = $total;
207 }
elseif ($after ==
'first') {
208 $totals = [$total->getCode() => $total];
209 $this->_totals = array_merge(
$totals, $this->_totals);
211 $last = array_pop($this->_totals);
212 $this->_totals[$total->getCode()] = $total;
213 $this->_totals[$last->getCode()] = $last;
227 if ($before !==
null) {
228 if (!is_array($before)) {
231 foreach ($before as $beforeTotals) {
232 if (isset($this->_totals[$beforeTotals])) {
235 if (
$code == $beforeTotals) {
236 $totals[$total->getCode()] = $total;
246 $first = array_shift($this->_totals);
247 $totals[$first->getCode()] = $first;
248 $totals[$total->getCode()] = $total;
264 if (isset($this->_totals[
$code])) {
265 return $this->_totals[
$code];
278 unset($this->_totals[
$code]);
298 function ($code1, $code2) use (
$order) {
314 if ($area ===
null) {
317 $area = (string)$area;
318 foreach ($this->_totals as $total) {
319 $totalArea = (string)$total->getArea();
320 if ($totalArea == $area) {
336 if (!$total->getIsFormated()) {
337 return $this->
getOrder()->formatPrice($total->getValue());
339 return $total->getValue();
elseif(isset( $params[ 'redirect_parent']))
addTotal(\Magento\Framework\DataObject $total, $after=null)
addTotalBefore(\Magento\Framework\DataObject $total, $before=null)
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, array $data=[])