Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Totalbar.php
Go to the documentation of this file.
1 <?php
7 
16 class Totalbar extends \Magento\Sales\Block\Adminhtml\Order\AbstractOrder
17 {
23  protected $_totals = [];
24 
31  protected function _beforeToHtml()
32  {
33  if (!$this->getParentBlock()) {
34  throw new \Magento\Framework\Exception\LocalizedException(
35  __('Please correct the parent block for this block.')
36  );
37  }
38  $this->setOrder($this->getParentBlock()->getOrder());
39  $this->setSource($this->getParentBlock()->getSource());
40  $this->setCurrency($this->getParentBlock()->getOrder()->getOrderCurrency());
41 
42  foreach ($this->getParentBlock()->getOrderTotalbarData() as $v) {
43  $this->addTotal($v[0], $v[1], $v[2]);
44  }
45 
46  parent::_beforeToHtml();
47  }
48 
54  protected function getTotals()
55  {
56  return $this->_totals;
57  }
58 
67  public function addTotal($label, $value, $grand = false)
68  {
69  $this->_totals[] = ['label' => $label, 'value' => $value, 'grand' => $grand];
70  return $this;
71  }
72 }
__()
Definition: __.php:13
$label
Definition: details.phtml:21
$value
Definition: gender.phtml:16
addTotal($label, $value, $grand=false)
Definition: Totalbar.php:67