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

Public Member Functions

 getDiscountPercent ()
 
 getValue ()
 
 isPercentageDiscount ()
 
- Public Member Functions inherited from SpecialPrice
 __construct (Product $saleableItem, $quantity, CalculatorInterface $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, TimezoneInterface $localeDate)
 
 getValue ()
 
 getSpecialPrice ()
 
 getSpecialFromDate ()
 
 getSpecialToDate ()
 
 isScopeDateInInterval ()
 
 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 ()
 

Protected Attributes

 $percent
 
- Protected Attributes inherited from SpecialPrice
 $localeDate
 
- Protected Attributes inherited from AbstractPrice
 $amount
 
 $calculator
 
 $product
 
 $priceType
 
 $quantity
 
 $priceInfo
 
 $value
 
 $priceCurrency
 

Additional Inherited Members

- Data Fields inherited from SpecialPrice
const PRICE_CODE = 'special_price'
 
- Data Fields inherited from AbstractPrice
const PRICE_CODE = 'abstract_price'
 

Detailed Description

Special price model

Definition at line 14 of file SpecialPrice.php.

Member Function Documentation

◆ getDiscountPercent()

getDiscountPercent ( )

Returns discount percent

Returns
bool|float

Implements DiscountProviderInterface.

Definition at line 26 of file SpecialPrice.php.

27  {
28  if ($this->percent === null) {
29  $this->percent = parent::getValue();
30  }
31  return $this->percent;
32  }

◆ getRegularPrice()

getRegularPrice ( )
protected

Returns regular price

Returns
bool|float

Definition at line 60 of file SpecialPrice.php.

61  {
62  return $this->priceInfo->getPrice(RegularPrice::PRICE_CODE)->getValue();
63  }

◆ getValue()

getValue ( )

Returns price value

Returns
bool|float

Implements PriceInterface.

Definition at line 39 of file SpecialPrice.php.

40  {
41  if ($this->value !== null) {
42  return $this->value;
43  }
44 
45  $specialPrice = $this->getDiscountPercent();
46  if ($specialPrice) {
47  $regularPrice = $this->getRegularPrice();
48  $this->value = $regularPrice * ($specialPrice / 100);
49  } else {
50  $this->value = false;
51  }
52  return $this->value;
53  }
$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

◆ isPercentageDiscount()

isPercentageDiscount ( )
Returns
bool

Implements SpecialPriceInterface.

Definition at line 68 of file SpecialPrice.php.

69  {
70  return true;
71  }

Field Documentation

◆ $percent

$percent
protected

Definition at line 19 of file SpecialPrice.php.


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