Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Adjustment Class Reference
Inheritance diagram for Adjustment:
AdjustmentInterface

Public Member Functions

 __construct (WeeeHelper $weeeHelper, PriceCurrencyInterface $priceCurrency, $sortOrder=null)
 
 getAdjustmentCode ()
 
 isIncludedInBasePrice ()
 
 isIncludedInDisplayPrice ()
 
 extractAdjustment ($amount, SaleableInterface $saleableItem, $context=[])
 
 applyAdjustment ($amount, SaleableInterface $saleableItem, $context=[])
 
 isExcludedWith ($adjustmentCode)
 
 getSortOrder ()
 

Data Fields

const ADJUSTMENT_CODE = 'weee'
 

Protected Member Functions

 getAmount (SaleableInterface $saleableItem)
 

Protected Attributes

 $weeeHelper
 
 $sortOrder
 
 $priceCurrency
 

Detailed Description

Weee pricing adjustment

Definition at line 18 of file Adjustment.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( WeeeHelper  $weeeHelper,
PriceCurrencyInterface  $priceCurrency,
  $sortOrder = null 
)

Constructor

Parameters
WeeeHelper$weeeHelper
PriceCurrencyInterface$priceCurrency
int$sortOrder

Definition at line 51 of file Adjustment.php.

52  {
53  $this->weeeHelper = $weeeHelper;
54  $this->priceCurrency = $priceCurrency;
55  $this->sortOrder = $sortOrder;
56  }

Member Function Documentation

◆ applyAdjustment()

applyAdjustment (   $amount,
SaleableInterface  $saleableItem,
  $context = [] 
)

Apply adjustment amount and return result value

Parameters
float$amount
SaleableInterface$saleableItem
null | array$context
Returns
float

Implements AdjustmentInterface.

Definition at line 117 of file Adjustment.php.

118  {
120  return $amount;
121  }
122  return $amount + $this->getAmount($saleableItem);
123  }
getAmount(SaleableInterface $saleableItem)
Definition: Adjustment.php:143
$amount
Definition: order.php:14

◆ extractAdjustment()

extractAdjustment (   $amount,
SaleableInterface  $saleableItem,
  $context = [] 
)

Extract adjustment amount from the given amount value

Parameters
float$amount
SaleableInterface$saleableItem
null | array$context
Returns
float @SuppressWarnings(PHPMD.UnusedFormalParameter)

Implements AdjustmentInterface.

Definition at line 104 of file Adjustment.php.

105  {
106  return 0;
107  }

◆ getAdjustmentCode()

getAdjustmentCode ( )

Get adjustment code

Returns
string

Implements AdjustmentInterface.

Definition at line 63 of file Adjustment.php.

64  {
65  return self::ADJUSTMENT_CODE;
66  }

◆ getAmount()

getAmount ( SaleableInterface  $saleableItem)
protected

Obtain amount

Parameters
SaleableInterface$saleableItem
Returns
float

Definition at line 143 of file Adjustment.php.

144  {
145  $weeeAmount = $this->weeeHelper->getAmountExclTax($saleableItem);
146  $weeeAmount = $this->priceCurrency->convert($weeeAmount);
147  return $weeeAmount;
148  }

◆ getSortOrder()

getSortOrder ( )

Return sort order position

Returns
int

Implements AdjustmentInterface.

Definition at line 155 of file Adjustment.php.

156  {
157  return $this->sortOrder;
158  }

◆ isExcludedWith()

isExcludedWith (   $adjustmentCode)

Check if adjustment should be excluded from calculations along with the given adjustment

Parameters
string$adjustmentCode
Returns
bool

Implements AdjustmentInterface.

Definition at line 131 of file Adjustment.php.

132  {
133  return (($adjustmentCode == self::ADJUSTMENT_CODE) ||
134  ($adjustmentCode == \Magento\Tax\Pricing\Adjustment::ADJUSTMENT_CODE));
135  }

◆ isIncludedInBasePrice()

isIncludedInBasePrice ( )

Define if adjustment is included in base price (FPT is excluded from base price)

Returns
bool

Implements AdjustmentInterface.

Definition at line 74 of file Adjustment.php.

75  {
76  return false;
77  }

◆ isIncludedInDisplayPrice()

isIncludedInDisplayPrice ( )

Define if adjustment is included in display price

Returns
bool

Implements AdjustmentInterface.

Definition at line 84 of file Adjustment.php.

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  }

Field Documentation

◆ $priceCurrency

$priceCurrency
protected

Definition at line 42 of file Adjustment.php.

◆ $sortOrder

$sortOrder
protected

Definition at line 37 of file Adjustment.php.

◆ $weeeHelper

$weeeHelper
protected

Definition at line 30 of file Adjustment.php.

◆ ADJUSTMENT_CODE

const ADJUSTMENT_CODE = 'weee'

Adjustment code weee

Definition at line 23 of file Adjustment.php.


The documentation for this class was generated from the following file: