RegularPrice.php 861 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Catalog\Pricing\Price;
  7. use Magento\Framework\Pricing\Price\AbstractPrice;
  8. use Magento\Framework\Pricing\Price\BasePriceProviderInterface;
  9. /**
  10. * Class RegularPrice
  11. */
  12. class RegularPrice extends AbstractPrice implements BasePriceProviderInterface
  13. {
  14. /**
  15. * Price type
  16. */
  17. const PRICE_CODE = 'regular_price';
  18. /**
  19. * Get price value
  20. *
  21. * @return float
  22. */
  23. public function getValue()
  24. {
  25. if ($this->value === null) {
  26. $price = $this->product->getPrice();
  27. $priceInCurrentCurrency = $this->priceCurrency->convertAndRound($price);
  28. $this->value = $priceInCurrentCurrency ? (float)$priceInCurrentCurrency : 0;
  29. }
  30. return $this->value;
  31. }
  32. }