Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
WeeeConfigProvider.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Weee\Model;
7 
10 use Magento\Weee\Helper\Data as WeeeHelper;
11 use Magento\Weee\Model\Tax as WeeeDisplayConfig;
12 
14 {
18  protected $weeeHelper;
19 
23  protected $storeManager;
24 
28  protected $weeeConfig;
29 
35  public function __construct(
36  WeeeHelper $weeeHelper,
39  ) {
40  $this->weeeHelper = $weeeHelper;
41  $this->storeManager = $storeManager;
42  $this->weeeConfig = $weeeConfig;
43  }
44 
48  public function getConfig()
49  {
50  return [
51  'isDisplayPriceWithWeeeDetails' => $this->iDisplayPriceWithWeeeDetails(),
52  'isDisplayFinalPrice' => $this->isDisplayFinalPrice(),
53  'isWeeeEnabled' => $this->isWeeeEnabled(),
54  'isIncludedInSubtotal' => $this->isIncludedInSubtotal(),
55  'getIncludeWeeeFlag' => $this->getIncludeWeeeFlag()
56  ];
57  }
58 
62  private function getStoreId()
63  {
64  return $this->storeManager->getStore()->getId();
65  }
66 
72  public function iDisplayPriceWithWeeeDetails()
73  {
74  if (!$this->weeeHelper->isEnabled($this->getStoreId())) {
75  return false;
76  }
77 
78  $displayWeeeDetails = $this->weeeHelper->typeOfDisplay(
79  [WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL],
80  'cart',
81  $this->storeManager->getStore()->getId()
82  );
83  if (!$displayWeeeDetails) {
84  return false;
85  }
86  return true;
87  }
88 
94  public function isDisplayFinalPrice()
95  {
96  $flag = $this->weeeHelper->typeOfDisplay(
97  WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL,
98  'cart',
99  $this->storeManager->getStore()->getId()
100  );
101 
102  if (!$flag) {
103  return false;
104  }
105 
106  return true;
107  }
108 
114  public function isWeeeEnabled()
115  {
116  return $this->weeeHelper->isEnabled($this->storeManager->getStore()->getId());
117  }
118 
124  public function getIncludeWeeeFlag()
125  {
126  $includeWeee = $this->weeeHelper->typeOfDisplay(
127  [WeeeDisplayConfig::DISPLAY_INCL_DESCR, WeeeDisplayConfig::DISPLAY_INCL],
128  'cart',
129  $this->getStoreId()
130  );
131  return $includeWeee;
132  }
133 
139  public function isIncludedInSubtotal()
140  {
141  return $this->weeeConfig->isEnabled() && $this->weeeConfig->includeInSubtotal();
142  }
143 }
__construct(WeeeHelper $weeeHelper, StoreManagerInterface $storeManager, Config $weeeConfig)