Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Adjustments.php
Go to the documentation of this file.
1 <?php
7 
9 
15 {
21  protected $_source;
22 
28  protected $_taxConfig;
29 
33  protected $priceCurrency;
34 
41  public function __construct(
42  \Magento\Backend\Block\Template\Context $context,
43  \Magento\Tax\Model\Config $taxConfig,
45  array $data = []
46  ) {
47  $this->_taxConfig = $taxConfig;
48  $this->priceCurrency = $priceCurrency;
49  parent::__construct($context, $data);
50  }
51 
57  public function initTotals()
58  {
59  $parent = $this->getParentBlock();
60  $this->_source = $parent->getSource();
61  $total = new \Magento\Framework\DataObject(['code' => 'agjustments', 'block_name' => $this->getNameInLayout()]);
62  $parent->removeTotal('shipping');
63  $parent->removeTotal('adjustment_positive');
64  $parent->removeTotal('adjustment_negative');
65  $parent->addTotal($total);
66  return $this;
67  }
68 
74  public function getSource()
75  {
76  return $this->_source;
77  }
78 
84  public function getShippingAmount()
85  {
86  $source = $this->getSource();
87  if ($this->_taxConfig->displaySalesShippingInclTax($source->getOrder()->getStoreId())) {
88  $shipping = $source->getBaseShippingInclTax();
89  } else {
90  $shipping = $source->getBaseShippingAmount();
91  }
92  return $this->priceCurrency->round($shipping) * 1;
93  }
94 
100  public function getShippingLabel()
101  {
102  $source = $this->getSource();
103  if ($this->_taxConfig->displaySalesShippingInclTax($source->getOrder()->getStoreId())) {
104  $label = __('Refund Shipping (Incl. Tax)');
105  } elseif ($this->_taxConfig->displaySalesShippingBoth($source->getOrder()->getStoreId())) {
106  $label = __('Refund Shipping (Excl. Tax)');
107  } else {
108  $label = __('Refund Shipping');
109  }
110  return $label;
111  }
112 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$source
Definition: source.php:23
__()
Definition: __.php:13
$label
Definition: details.phtml:21
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Tax\Model\Config $taxConfig, PriceCurrencyInterface $priceCurrency, array $data=[])
Definition: Adjustments.php:41