Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
TaxConfigProvider Class Reference
Inheritance diagram for TaxConfigProvider:
ConfigProviderInterface

Public Member Functions

 __construct (TaxHelper $taxHelper, Config $taxConfig, CheckoutSession $checkoutSession, ScopeConfigInterface $scopeConfig)
 
 getConfig ()
 
 getDisplayShippingMode ()
 
 isDisplayShippingPriceExclTax ()
 
 isDisplayShippingBothPrices ()
 
 getReviewItemPriceDisplayMode ()
 
 getReviewTotalsDisplayMode ()
 
 isFullTaxSummaryDisplayed ()
 
 isTaxDisplayedInGrandTotal ()
 

Protected Member Functions

 reloadOnBillingAddress ()
 

Protected Attributes

 $taxHelper
 
 $taxConfig
 
 $scopeConfig
 
 $checkoutSession
 

Detailed Description

Definition at line 13 of file TaxConfigProvider.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( TaxHelper  $taxHelper,
Config  $taxConfig,
CheckoutSession  $checkoutSession,
ScopeConfigInterface  $scopeConfig 
)
Parameters
TaxHelper$taxHelper
Config$taxConfig
CheckoutSession$checkoutSession
ScopeConfigInterface$scopeConfig

Definition at line 41 of file TaxConfigProvider.php.

46  {
47  $this->taxHelper = $taxHelper;
48  $this->taxConfig = $taxConfig;
49  $this->checkoutSession = $checkoutSession;
50  $this->scopeConfig = $scopeConfig;
51  }

Member Function Documentation

◆ getConfig()

getConfig ( )

{Retrieve assoc array of checkout configuration

Returns
array
}

Implements ConfigProviderInterface.

Definition at line 56 of file TaxConfigProvider.php.

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  }
const CONFIG_XML_PATH_DEFAULT_POSTCODE
Definition: Config.php:55
const CONFIG_XML_PATH_DEFAULT_REGION
Definition: Config.php:53
const CONFIG_XML_PATH_DEFAULT_COUNTRY
Definition: Config.php:51

◆ getDisplayShippingMode()

getDisplayShippingMode ( )

Shipping mode: 'both', 'including', 'excluding'

Returns
string

Definition at line 93 of file TaxConfigProvider.php.

94  {
95  if ($this->taxConfig->displayCartShippingBoth()) {
96  return 'both';
97  }
98  if ($this->taxConfig->displayCartShippingExclTax()) {
99  return 'excluding';
100  }
101  return 'including';
102  }

◆ getReviewItemPriceDisplayMode()

getReviewItemPriceDisplayMode ( )

Get review item price display mode

Returns
string 'both', 'including', 'excluding'

Definition at line 129 of file TaxConfigProvider.php.

130  {
131  if ($this->taxHelper->displayCartBothPrices()) {
132  return 'both';
133  }
134  if ($this->taxHelper->displayCartPriceExclTax()) {
135  return 'excluding';
136  }
137  return 'including';
138  }

◆ getReviewTotalsDisplayMode()

getReviewTotalsDisplayMode ( )

Get review item price display mode

Returns
string 'both', 'including', 'excluding'

Definition at line 145 of file TaxConfigProvider.php.

146  {
147  if ($this->taxConfig->displayCartSubtotalBoth()) {
148  return 'both';
149  }
150  if ($this->taxConfig->displayCartSubtotalExclTax()) {
151  return 'excluding';
152  }
153  return 'including';
154  }

◆ isDisplayShippingBothPrices()

isDisplayShippingBothPrices ( )

Return flag whether to display shipping price including and excluding tax

Returns
bool

Definition at line 119 of file TaxConfigProvider.php.

120  {
121  return $this->taxHelper->displayShippingBothPrices();
122  }

◆ isDisplayShippingPriceExclTax()

isDisplayShippingPriceExclTax ( )

Return flag whether to display shipping price excluding tax

Returns
bool

Definition at line 109 of file TaxConfigProvider.php.

110  {
111  return $this->taxHelper->displayShippingPriceExcludingTax();
112  }

◆ isFullTaxSummaryDisplayed()

isFullTaxSummaryDisplayed ( )

Show tax details in checkout totals section flag

Returns
bool

Definition at line 161 of file TaxConfigProvider.php.

162  {
163  return $this->taxHelper->displayFullSummary();
164  }

◆ isTaxDisplayedInGrandTotal()

isTaxDisplayedInGrandTotal ( )

Display tax in grand total section or not

Returns
bool

Definition at line 171 of file TaxConfigProvider.php.

172  {
173  return $this->taxConfig->displayCartTaxWithGrandTotal();
174  }

◆ reloadOnBillingAddress()

reloadOnBillingAddress ( )
protected

Reload totals(taxes) on billing address update

Returns
bool

Definition at line 181 of file TaxConfigProvider.php.

182  {
183  $quote = $this->checkoutSession->getQuote();
184  $configValue = $this->scopeConfig->getValue(
187  );
188  return 'billing' == $configValue || $quote->isVirtual();
189  }
$quote
const CONFIG_XML_PATH_BASED_ON
Definition: Config.php:38

Field Documentation

◆ $checkoutSession

$checkoutSession
protected

Definition at line 33 of file TaxConfigProvider.php.

◆ $scopeConfig

$scopeConfig
protected

Definition at line 28 of file TaxConfigProvider.php.

◆ $taxConfig

$taxConfig
protected

Definition at line 23 of file TaxConfigProvider.php.

◆ $taxHelper

$taxHelper
protected

Definition at line 18 of file TaxConfigProvider.php.


The documentation for this class was generated from the following file: