Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Adjustment.php
Go to the documentation of this file.
1 <?php
8 
13 
18 {
24  protected $weeeHelper;
25 
29  protected $finalAmount;
30 
39  public function __construct(
40  Template\Context $context,
42  \Magento\Weee\Helper\Data $weeeHelper,
43  array $data = []
44  ) {
45  $this->weeeHelper = $weeeHelper;
46  parent::__construct($context, $priceCurrency, $data);
47  }
48 
52  protected function apply()
53  {
54  $weeeAmount = $this->amountRender->getAmount()->getAdjustmentAmount($this->getAdjustmentCode());
55  $weeeTaxAmount =
56  $this->amountRender->getAmount()->getAdjustmentAmount(\Magento\Weee\Pricing\TaxAdjustment::ADJUSTMENT_CODE);
57 
58  $this->finalAmount = $this->amountRender->getDisplayValue();
59 
61  $this->amountRender->setDisplayValue(
62  $this->amountRender->getDisplayValue() - $weeeAmount - $weeeTaxAmount
63  );
64  }
65  return $this->toHtml();
66  }
67 
71  public function getRawFinalAmount()
72  {
73  return $this->finalAmount;
74  }
75 
81  public function getAdjustmentCode()
82  {
83  return \Magento\Weee\Pricing\Adjustment::ADJUSTMENT_CODE;
84  }
85 
89  public function getFinalAmount()
90  {
91  return $this->formatCurrency($this->finalAmount);
92  }
93 
99  protected function getWeeeAmount()
100  {
101  $product = $this->getSaleableItem();
102  return $this->weeeHelper->getAmountExclTax($product);
103  }
104 
110  public function showInclDescr()
111  {
112  return $this->isWeeeShown() && $this->getWeeeAmount() && $this->typeOfDisplay(Tax::DISPLAY_INCL_DESCR);
113  }
114 
120  public function showExclDescrIncl()
121  {
122  return $this->isWeeeShown() && $this->getWeeeAmount() && $this->typeOfDisplay(Tax::DISPLAY_EXCL_DESCR_INCL);
123  }
124 
130  public function getWeeeTaxAttributes()
131  {
132  return $this->isWeeeShown() ? $this->getWeeeAttributesForDisplay() : [];
133  }
134 
141  public function renderWeeeTaxAttributeName(\Magento\Framework\DataObject $attribute)
142  {
143  return $attribute->getData('name');
144  }
145 
152  public function renderWeeeTaxAttribute(\Magento\Framework\DataObject $attribute)
153  {
154  return $this->convertAndFormatCurrency($attribute->getData('amount'));
155  }
156 
163  public function renderWeeeTaxAttributeWithTax(\Magento\Framework\DataObject $attribute)
164  {
165  return $this->convertAndFormatCurrency(
166  $attribute->getData('amount_excl_tax') + $attribute->getData('tax_amount')
167  );
168  }
169 
176  public function renderWeeeTaxAttributeWithoutTax(\Magento\Framework\DataObject $attribute)
177  {
178  $price = $attribute->getData('amount_excl_tax');
179  return ($price > 0) ? $this->convertAndFormatCurrency($price): $this->convertAndFormatCurrency(0);
180  }
181 
189  protected function typeOfDisplay($compareTo = null, $store = null)
190  {
191  return $this->weeeHelper->typeOfDisplay($compareTo, $this->getZone(), $store);
192  }
193 
199  protected function getWeeeAttributesForDisplay()
200  {
201  $product = $this->getSaleableItem();
202  return $this->weeeHelper->getProductWeeeAttributesForDisplay($product);
203  }
204 
210  protected function isWeeeShown()
211  {
213  return $isWeeeShown;
214  }
215 
221  public function getTaxDisplayConfig()
222  {
223  $showPriceWithTax = $this->weeeHelper->getTaxDisplayConfig();
224  return $showPriceWithTax;
225  }
226 
232  public function isPriceIncludesTax()
233  {
234  $showPriceWithTax = $this->weeeHelper->displayTotalsInclTax();
235  return $showPriceWithTax;
236  }
237 }
renderWeeeTaxAttributeWithTax(\Magento\Framework\DataObject $attribute)
Definition: Adjustment.php:163
const DISPLAY_INCL_DESCR
Definition: Tax.php:30
$price
__construct(Template\Context $context, PriceCurrencyInterface $priceCurrency, \Magento\Weee\Helper\Data $weeeHelper, array $data=[])
Definition: Adjustment.php:39
typeOfDisplay($compareTo=null, $store=null)
Definition: Adjustment.php:189
renderWeeeTaxAttribute(\Magento\Framework\DataObject $attribute)
Definition: Adjustment.php:152
renderWeeeTaxAttributeWithoutTax(\Magento\Framework\DataObject $attribute)
Definition: Adjustment.php:176
renderWeeeTaxAttributeName(\Magento\Framework\DataObject $attribute)
Definition: Adjustment.php:141
convertAndFormatCurrency( $amount, $includeContainer=true, $precision=PriceCurrencyInterface::DEFAULT_PRECISION)
const DISPLAY_EXCL_DESCR_INCL
Definition: Tax.php:35
formatCurrency( $amount, $includeContainer=true, $precision=PriceCurrencyInterface::DEFAULT_PRECISION)