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
8 
10 
16 {
22  public function __construct(
23  \Magento\Framework\View\Element\Template\Context $context,
24  \Magento\Framework\Registry $registry,
25  array $data = []
26  ) {
27  parent::__construct($context, $registry, $data);
28  $this->_isScopePrivate = true;
29  }
30 
34  protected $_creditmemo = null;
35 
39  public function getCreditmemo()
40  {
41  if ($this->_creditmemo === null) {
42  if ($this->hasData('creditmemo')) {
43  $this->_creditmemo = $this->_getData('creditmemo');
44  } elseif ($this->_coreRegistry->registry('current_creditmemo')) {
45  $this->_creditmemo = $this->_coreRegistry->registry('current_creditmemo');
46  } elseif ($this->getParentBlock()->getCreditmemo()) {
47  $this->_creditmemo = $this->getParentBlock()->getCreditmemo();
48  }
49  }
50  return $this->_creditmemo;
51  }
52 
57  public function setCreditmemo($creditmemo)
58  {
59  $this->_creditmemo = $creditmemo;
60  return $this;
61  }
62 
68  public function getSource()
69  {
70  return $this->getCreditmemo();
71  }
72 
78  protected function _initTotals()
79  {
80  parent::_initTotals();
81  $this->removeTotal('base_grandtotal');
82  if ((double)$this->getSource()->getAdjustmentPositive()) {
83  $total = new \Magento\Framework\DataObject(
84  [
85  'code' => 'adjustment_positive',
86  'value' => $this->getSource()->getAdjustmentPositive(),
87  'label' => __('Adjustment Refund'),
88  ]
89  );
90  $this->addTotal($total);
91  }
92  if ((double)$this->getSource()->getAdjustmentNegative()) {
93  $total = new \Magento\Framework\DataObject(
94  [
95  'code' => 'adjustment_negative',
96  'value' => $this->getSource()->getAdjustmentNegative(),
97  'label' => __('Adjustment Fee'),
98  ]
99  );
100  $this->addTotal($total);
101  }
122  return $this;
123  }
124 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
__()
Definition: __.php:13
addTotal(\Magento\Framework\DataObject $total, $after=null)
Definition: Totals.php:187
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry, array $data=[])
Definition: Totals.php:22