Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Price.php
Go to the documentation of this file.
1 <?php
7 
9 
15 {
19  protected $taxHelper;
20 
29  public function __construct(
30  \Magento\Framework\View\Element\Template\Context $context,
31  \Magento\Customer\Model\Session $customerSession,
32  \Magento\Checkout\Model\Session $checkoutSession,
34  \Magento\Tax\Helper\Data $taxHelper,
35  array $data = []
36  ) {
37  $this->taxHelper = $taxHelper;
38  parent::__construct(
39  $context,
40  $customerSession,
41  $checkoutSession,
43  $data
44  );
45  }
46 
53  protected function getShippingPriceWithFlag($flag)
54  {
55  $price = $this->taxHelper->getShippingPrice(
56  $this->getShippingRate()->getPrice(),
57  $flag,
58  $this->getAddress(),
59  $this->getQuote()->getCustomerTaxClassId()
60  );
61 
62  return $this->priceCurrency->convertAndFormat(
63  $price,
64  true,
65  PriceCurrencyInterface::DEFAULT_PRECISION,
66  $this->getQuote()->getStore()
67  );
68  }
69 
75  public function getShippingPriceExclTax()
76  {
77  return $this->getShippingPriceWithFlag(false);
78  }
79 
85  public function getShippingPriceInclTax()
86  {
87  return $this->getShippingPriceWithFlag(true);
88  }
89 
95  public function displayShippingPriceInclTax()
96  {
97  return $this->taxHelper->displayShippingPriceIncludingTax();
98  }
99 
105  public function displayShippingPriceExclTax()
106  {
107  return $this->taxHelper->displayShippingPriceExcludingTax();
108  }
109 
115  public function displayShippingBothPrices()
116  {
117  return $this->taxHelper->displayShippingBothPrices();
118  }
119 }
$price
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, PriceCurrencyInterface $priceCurrency, \Magento\Tax\Helper\Data $taxHelper, array $data=[])
Definition: Price.php:29