Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SpecialPrice.php
Go to the documentation of this file.
1 <?php
8 
14 
19 {
23  const PRICE_CODE = 'special_price';
24 
28  protected $localeDate;
29 
37  public function __construct(
38  Product $saleableItem,
39  $quantity,
43  ) {
44  parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency);
45  $this->localeDate = $localeDate;
46  }
47 
51  public function getValue()
52  {
53  if (null === $this->value) {
54  $this->value = false;
55  $specialPrice = $this->getSpecialPrice();
56  if ($specialPrice !== null && $specialPrice !== false && $this->isScopeDateInInterval()) {
57  $this->value = (float) $specialPrice;
58  }
59  }
60 
61  return $this->value;
62  }
63 
69  public function getSpecialPrice()
70  {
71  $specialPrice = $this->product->getSpecialPrice();
72  if ($specialPrice !== null && $specialPrice !== false && !$this->isPercentageDiscount()) {
73  $specialPrice = $this->priceCurrency->convertAndRound($specialPrice);
74  }
75  return $specialPrice;
76  }
77 
83  public function getSpecialFromDate()
84  {
85  return $this->product->getSpecialFromDate();
86  }
87 
93  public function getSpecialToDate()
94  {
95  return $this->product->getSpecialToDate();
96  }
97 
101  public function isScopeDateInInterval()
102  {
103  return $this->localeDate->isScopeDateInInterval(
104  $this->product->getStore(),
105  $this->getSpecialFromDate(),
106  $this->getSpecialToDate()
107  );
108  }
109 
113  public function isPercentageDiscount()
114  {
115  return false;
116  }
117 }
$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
__construct(Product $saleableItem, $quantity, CalculatorInterface $calculator, \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, TimezoneInterface $localeDate)