Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TaxConfigProvider.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Tax\Model;
7 
9 use Magento\Tax\Helper\Data as TaxHelper;
12 
14 {
18  protected $taxHelper;
19 
23  protected $taxConfig;
24 
28  protected $scopeConfig;
29 
33  protected $checkoutSession;
34 
41  public function __construct(
42  TaxHelper $taxHelper,
46  ) {
47  $this->taxHelper = $taxHelper;
48  $this->taxConfig = $taxConfig;
49  $this->checkoutSession = $checkoutSession;
50  $this->scopeConfig = $scopeConfig;
51  }
52 
56  public function getConfig()
57  {
58  $defaultRegionId = $this->scopeConfig->getValue(
61  );
62  // prevent wrong assignment on shipping rate estimation requests
63  if (0 == $defaultRegionId) {
64  $defaultRegionId = null;
65  }
66  return [
67  'isDisplayShippingPriceExclTax' => $this->isDisplayShippingPriceExclTax(),
68  'isDisplayShippingBothPrices' => $this->isDisplayShippingBothPrices(),
69  'reviewShippingDisplayMode' => $this->getDisplayShippingMode(),
70  'reviewItemPriceDisplayMode' => $this->getReviewItemPriceDisplayMode(),
71  'reviewTotalsDisplayMode' => $this->getReviewTotalsDisplayMode(),
72  'includeTaxInGrandTotal' => $this->isTaxDisplayedInGrandTotal(),
73  'isFullTaxSummaryDisplayed' => $this->isFullTaxSummaryDisplayed(),
74  'isZeroTaxDisplayed' => $this->taxConfig->displayCartZeroTax(),
75  'reloadOnBillingAddress' => $this->reloadOnBillingAddress(),
76  'defaultCountryId' => $this->scopeConfig->getValue(
79  ),
80  'defaultRegionId' => $defaultRegionId,
81  'defaultPostcode' => $this->scopeConfig->getValue(
84  ),
85  ];
86  }
87 
93  public function getDisplayShippingMode()
94  {
95  if ($this->taxConfig->displayCartShippingBoth()) {
96  return 'both';
97  }
98  if ($this->taxConfig->displayCartShippingExclTax()) {
99  return 'excluding';
100  }
101  return 'including';
102  }
103 
110  {
111  return $this->taxHelper->displayShippingPriceExcludingTax();
112  }
113 
119  public function isDisplayShippingBothPrices()
120  {
121  return $this->taxHelper->displayShippingBothPrices();
122  }
123 
130  {
131  if ($this->taxHelper->displayCartBothPrices()) {
132  return 'both';
133  }
134  if ($this->taxHelper->displayCartPriceExclTax()) {
135  return 'excluding';
136  }
137  return 'including';
138  }
139 
145  public function getReviewTotalsDisplayMode()
146  {
147  if ($this->taxConfig->displayCartSubtotalBoth()) {
148  return 'both';
149  }
150  if ($this->taxConfig->displayCartSubtotalExclTax()) {
151  return 'excluding';
152  }
153  return 'including';
154  }
155 
161  public function isFullTaxSummaryDisplayed()
162  {
163  return $this->taxHelper->displayFullSummary();
164  }
165 
171  public function isTaxDisplayedInGrandTotal()
172  {
173  return $this->taxConfig->displayCartTaxWithGrandTotal();
174  }
175 
181  protected function reloadOnBillingAddress()
182  {
183  $quote = $this->checkoutSession->getQuote();
184  $configValue = $this->scopeConfig->getValue(
187  );
188  return 'billing' == $configValue || $quote->isVirtual();
189  }
190 }
const CONFIG_XML_PATH_DEFAULT_POSTCODE
Definition: Config.php:55
$quote
const CONFIG_XML_PATH_DEFAULT_REGION
Definition: Config.php:53
const CONFIG_XML_PATH_DEFAULT_COUNTRY
Definition: Config.php:51
const CONFIG_XML_PATH_BASED_ON
Definition: Config.php:38
__construct(TaxHelper $taxHelper, Config $taxConfig, CheckoutSession $checkoutSession, ScopeConfigInterface $scopeConfig)