Price.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Checkout\Block\Shipping;
  7. use Magento\Checkout\Block\Cart\AbstractCart;
  8. use Magento\Framework\Pricing\PriceCurrencyInterface;
  9. use Magento\Quote\Model\Quote\Address\Rate;
  10. /**
  11. * Class Price
  12. * @deprecated 100.1.0
  13. */
  14. class Price extends AbstractCart
  15. {
  16. /**
  17. * @var Rate
  18. */
  19. protected $shippingRate;
  20. /**
  21. * @var PriceCurrencyInterface
  22. */
  23. protected $priceCurrency;
  24. /**
  25. * @param \Magento\Framework\View\Element\Template\Context $context
  26. * @param \Magento\Customer\Model\Session $customerSession
  27. * @param \Magento\Checkout\Model\Session $checkoutSession
  28. * @param PriceCurrencyInterface $priceCurrency
  29. * @param array $data
  30. */
  31. public function __construct(
  32. \Magento\Framework\View\Element\Template\Context $context,
  33. \Magento\Customer\Model\Session $customerSession,
  34. \Magento\Checkout\Model\Session $checkoutSession,
  35. PriceCurrencyInterface $priceCurrency,
  36. array $data = []
  37. ) {
  38. $this->priceCurrency = $priceCurrency;
  39. parent::__construct($context, $customerSession, $checkoutSession, $data);
  40. }
  41. /**
  42. * Set the shipping rate
  43. *
  44. * @param Rate $shippingRate
  45. * @return $this
  46. */
  47. public function setShippingRate(Rate $shippingRate)
  48. {
  49. $this->shippingRate = $shippingRate;
  50. return $this;
  51. }
  52. /**
  53. * Return shipping rate
  54. *
  55. * @return Rate
  56. */
  57. public function getShippingRate()
  58. {
  59. return $this->shippingRate;
  60. }
  61. /**
  62. * Get Shipping Price
  63. *
  64. * @return float
  65. */
  66. public function getShippingPrice()
  67. {
  68. return $this->priceCurrency->convertAndFormat($this->shippingRate->getPrice());
  69. }
  70. }