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 use Magento\Weee\Helper\Data as WeeeHelper;
14 
19 {
23  const ADJUSTMENT_CODE = 'weee';
24 
30  protected $weeeHelper;
31 
37  protected $sortOrder;
38 
42  protected $priceCurrency;
43 
52  {
53  $this->weeeHelper = $weeeHelper;
54  $this->priceCurrency = $priceCurrency;
55  $this->sortOrder = $sortOrder;
56  }
57 
63  public function getAdjustmentCode()
64  {
65  return self::ADJUSTMENT_CODE;
66  }
67 
74  public function isIncludedInBasePrice()
75  {
76  return false;
77  }
78 
84  public function isIncludedInDisplayPrice()
85  {
86  return $this->weeeHelper->typeOfDisplay(
87  [
88  \Magento\Weee\Model\Tax::DISPLAY_INCL,
89  \Magento\Weee\Model\Tax::DISPLAY_INCL_DESCR,
90  \Magento\Weee\Model\Tax::DISPLAY_EXCL_DESCR_INCL,
91  ]
92  );
93  }
94 
104  public function extractAdjustment($amount, SaleableInterface $saleableItem, $context = [])
105  {
106  return 0;
107  }
108 
117  public function applyAdjustment($amount, SaleableInterface $saleableItem, $context = [])
118  {
120  return $amount;
121  }
122  return $amount + $this->getAmount($saleableItem);
123  }
124 
131  public function isExcludedWith($adjustmentCode)
132  {
133  return (($adjustmentCode == self::ADJUSTMENT_CODE) ||
134  ($adjustmentCode == \Magento\Tax\Pricing\Adjustment::ADJUSTMENT_CODE));
135  }
136 
143  protected function getAmount(SaleableInterface $saleableItem)
144  {
145  $weeeAmount = $this->weeeHelper->getAmountExclTax($saleableItem);
146  $weeeAmount = $this->priceCurrency->convert($weeeAmount);
147  return $weeeAmount;
148  }
149 
155  public function getSortOrder()
156  {
157  return $this->sortOrder;
158  }
159 }
applyAdjustment($amount, SaleableInterface $saleableItem, $context=[])
Definition: Adjustment.php:117
extractAdjustment($amount, SaleableInterface $saleableItem, $context=[])
Definition: Adjustment.php:104
getAmount(SaleableInterface $saleableItem)
Definition: Adjustment.php:143
__construct(WeeeHelper $weeeHelper, PriceCurrencyInterface $priceCurrency, $sortOrder=null)
Definition: Adjustment.php:51
$amount
Definition: order.php:14
isExcludedWith($adjustmentCode)
Definition: Adjustment.php:131