Price.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Tax\Block\Checkout\Shipping;
  7. use Magento\Framework\Pricing\PriceCurrencyInterface;
  8. /**
  9. * Class Price
  10. * @deprecated 100.1.0
  11. */
  12. class Price extends \Magento\Checkout\Block\Shipping\Price
  13. {
  14. /**
  15. * @var \Magento\Tax\Helper\Data
  16. */
  17. protected $taxHelper;
  18. /**
  19. * @param \Magento\Framework\View\Element\Template\Context $context
  20. * @param \Magento\Customer\Model\Session $customerSession
  21. * @param \Magento\Checkout\Model\Session $checkoutSession
  22. * @param PriceCurrencyInterface $priceCurrency
  23. * @param \Magento\Tax\Helper\Data $taxHelper
  24. * @param array $data
  25. */
  26. public function __construct(
  27. \Magento\Framework\View\Element\Template\Context $context,
  28. \Magento\Customer\Model\Session $customerSession,
  29. \Magento\Checkout\Model\Session $checkoutSession,
  30. PriceCurrencyInterface $priceCurrency,
  31. \Magento\Tax\Helper\Data $taxHelper,
  32. array $data = []
  33. ) {
  34. $this->taxHelper = $taxHelper;
  35. parent::__construct(
  36. $context,
  37. $customerSession,
  38. $checkoutSession,
  39. $priceCurrency,
  40. $data
  41. );
  42. }
  43. /**
  44. * Get Shipping Price including or excluding tax
  45. *
  46. * @param bool $flag
  47. * @return float
  48. */
  49. protected function getShippingPriceWithFlag($flag)
  50. {
  51. $price = $this->taxHelper->getShippingPrice(
  52. $this->getShippingRate()->getPrice(),
  53. $flag,
  54. $this->getAddress(),
  55. $this->getQuote()->getCustomerTaxClassId()
  56. );
  57. return $this->priceCurrency->convertAndFormat(
  58. $price,
  59. true,
  60. PriceCurrencyInterface::DEFAULT_PRECISION,
  61. $this->getQuote()->getStore()
  62. );
  63. }
  64. /**
  65. * Get shipping price excluding tax
  66. *
  67. * @return float
  68. */
  69. public function getShippingPriceExclTax()
  70. {
  71. return $this->getShippingPriceWithFlag(false);
  72. }
  73. /**
  74. * Get shipping price including tax
  75. *
  76. * @return float
  77. */
  78. public function getShippingPriceInclTax()
  79. {
  80. return $this->getShippingPriceWithFlag(true);
  81. }
  82. /**
  83. * Return flag whether to display shipping price including tax
  84. *
  85. * @return bool
  86. */
  87. public function displayShippingPriceInclTax()
  88. {
  89. return $this->taxHelper->displayShippingPriceIncludingTax();
  90. }
  91. /**
  92. * Return flag whether to display shipping price excluding tax
  93. *
  94. * @return bool
  95. */
  96. public function displayShippingPriceExclTax()
  97. {
  98. return $this->taxHelper->displayShippingPriceExcludingTax();
  99. }
  100. /**
  101. * Return flag whether to display shipping price including and excluding tax
  102. *
  103. * @return bool
  104. */
  105. public function displayShippingBothPrices()
  106. {
  107. return $this->taxHelper->displayShippingBothPrices();
  108. }
  109. }