Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Totals.php
Go to the documentation of this file.
1 <?php
7 
13 {
17  protected $weeeData;
18 
24  public function __construct(
25  \Magento\Framework\View\Element\Template\Context $context,
26  \Magento\Weee\Helper\Data $weeeData,
27  array $data = []
28  ) {
29  $this->weeeData = $weeeData;
30  parent::__construct($context, $data);
31  }
32 
38  public function getSource()
39  {
40  return $this->getParentBlock()->getSource();
41  }
42 
48  public function initTotals()
49  {
51  $items = $this->getSource()->getAllItems();
52  $store = $this->getSource()->getStore();
53 
54  $weeeTotal = $this->weeeData->getTotalAmounts($items, $store);
55  $weeeBaseTotal = $this->weeeData->getBaseTotalAmounts($items, $store);
56  if ($weeeTotal) {
57  // Add our total information to the set of other totals
58  $total = new \Magento\Framework\DataObject(
59  [
60  'code' => $this->getNameInLayout(),
61  'label' => __('FPT'),
62  'value' => $weeeTotal,
63  'base_value' => $weeeBaseTotal
64  ]
65  );
66  if ($this->getBeforeCondition()) {
67  $this->getParentBlock()->addTotalBefore($total, $this->getBeforeCondition());
68  } else {
69  $this->getParentBlock()->addTotal($total, $this->getAfterCondition());
70  }
71  }
72  return $this;
73  }
74 }
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Weee\Helper\Data $weeeData, array $data=[])
Definition: Totals.php:24
__()
Definition: __.php:13
$items