Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
TierPrice Class Reference
Inheritance diagram for TierPrice:
TierPrice DiscountProviderInterface AbstractPrice TierPriceInterface BasePriceProviderInterface PriceInterface

Public Member Functions

 getDiscountPercent ()
 
 getValue ()
 
 isPercentageDiscount ()
 
- Public Member Functions inherited from TierPrice
 __construct (Product $saleableItem, $quantity, CalculatorInterface $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, Session $customerSession, GroupManagementInterface $groupManagement, CustomerGroupRetrieverInterface $customerGroupRetriever=null)
 
 getValue ()
 
 getTierPriceCount ()
 
 getTierPriceList ()
 
 getSavePercent (AmountInterface $amount)
 
 isPercentageDiscount ()
 
- Public Member Functions inherited from AbstractPrice
 __construct (SaleableInterface $saleableItem, $quantity, CalculatorInterface $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency)
 
 getValue ()
 
 getAmount ()
 
 getCustomAmount ($amount=null, $exclude=null, $context=[])
 
 getPriceCode ()
 
 getProduct ()
 
 getQuantity ()
 

Protected Member Functions

 getRegularPrice ()
 
 isFirstPriceBetter ($firstPrice, $secondPrice)
 
- Protected Member Functions inherited from TierPrice
 isFirstPriceBetter ($firstPrice, $secondPrice)
 
 filterTierPrices (array $priceList)
 
 applyAdjustment ($price)
 
 canApplyTierPrice (array $currentTierPrice, $prevPriceGroup, $prevQty)
 

Protected Attributes

 $filterByBasePrice = false
 
 $percent
 
- Protected Attributes inherited from TierPrice
 $customerSession
 
 $customerGroup
 
 $rawPriceList
 
 $priceList
 
 $groupManagement
 
- Protected Attributes inherited from AbstractPrice
 $amount
 
 $calculator
 
 $product
 
 $priceType
 
 $quantity
 
 $priceInfo
 
 $value
 
 $priceCurrency
 

Additional Inherited Members

- Data Fields inherited from TierPrice
const PRICE_CODE = 'tier_price'
 
- Data Fields inherited from AbstractPrice
const PRICE_CODE = 'abstract_price'
 

Detailed Description

Bundle tier prices model

Definition at line 16 of file TierPrice.php.

Member Function Documentation

◆ getDiscountPercent()

getDiscountPercent ( )

Returns percent discount

Returns
bool|float

Implements DiscountProviderInterface.

Definition at line 33 of file TierPrice.php.

34  {
35  if ($this->percent === null) {
36  $prices = $this->getStoredTierPrices();
38  $this->value = $prevPrice = false;
39  $priceGroup = $this->groupManagement->getAllCustomersGroup()->getId();
40 
41  foreach ($prices as $price) {
42  if (!$this->canApplyTierPrice($price, $priceGroup, $prevQty)
43  || !isset($price['percentage_value'])
44  || !is_numeric($price['percentage_value'])
45  ) {
46  continue;
47  }
48  if (false === $prevPrice || $this->isFirstPriceBetter($price['website_price'], $prevPrice)) {
49  $prevPrice = $price['website_price'];
50  $prevQty = $price['price_qty'];
51  $priceGroup = $price['cust_group'];
52  $this->percent = max(0, min(100, 100 - $price['percentage_value']));
53  }
54  }
55  }
56  return $this->percent;
57  }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
canApplyTierPrice(array $currentTierPrice, $prevPriceGroup, $prevQty)
Definition: TierPrice.php:251
$price
isFirstPriceBetter($firstPrice, $secondPrice)
Definition: TierPrice.php:99

◆ getRegularPrice()

getRegularPrice ( )
protected

Returns regular price

Returns
bool|float

Definition at line 85 of file TierPrice.php.

86  {
87  return $this->priceInfo->getPrice(RegularPrice::PRICE_CODE)->getValue();
88  }

◆ getValue()

getValue ( )

Returns pricing value

Returns
bool|float

Implements PriceInterface.

Definition at line 64 of file TierPrice.php.

65  {
66  if ($this->value !== null) {
67  return $this->value;
68  }
69 
70  $tierPrice = $this->getDiscountPercent();
71  if ($tierPrice) {
72  $regularPrice = $this->getRegularPrice();
73  $this->value = $regularPrice * ($tierPrice / 100);
74  } else {
75  $this->value = false;
76  }
77  return $this->value;
78  }
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9

◆ isFirstPriceBetter()

isFirstPriceBetter (   $firstPrice,
  $secondPrice 
)
protected

Returns true if first price is better

Method filters tiers price values, higher discount value is better

Parameters
float$firstPrice
float$secondPrice
Returns
bool

Definition at line 99 of file TierPrice.php.

100  {
101  return $firstPrice > $secondPrice;
102  }

◆ isPercentageDiscount()

isPercentageDiscount ( )
Returns
bool

Implements TierPriceInterface.

Definition at line 107 of file TierPrice.php.

108  {
109  return true;
110  }

Field Documentation

◆ $filterByBasePrice

$filterByBasePrice = false
protected

Definition at line 21 of file TierPrice.php.

◆ $percent

$percent
protected

Definition at line 26 of file TierPrice.php.


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