Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Notifications.php
Go to the documentation of this file.
1 <?php
7 
12 {
19  protected $storeManager;
20 
24  protected $urlBuilder;
25 
31  protected $taxConfig;
32 
41 
50 
54  private $notifications = [];
55 
62  public function __construct(
64  \Magento\Framework\UrlInterface $urlBuilder,
65  \Magento\Tax\Model\Config $taxConfig,
66  $notifications = []
67  ) {
68  $this->storeManager = $storeManager;
69  $this->urlBuilder = $urlBuilder;
70  $this->taxConfig = $taxConfig;
71  $this->notifications = $notifications;
72  }
73 
80  public function getIdentity()
81  {
82  return md5('TAX_NOTIFICATION');
83  }
84 
88  public function isDisplayed()
89  {
90  foreach ($this->notifications as $notification) {
91  if ($notification->isDisplayed()) {
92  return true;
93  }
94  }
95  return false;
96  }
97 
101  public function getText()
102  {
103  $messageDetails = '';
104 
105  foreach ($this->notifications as $notification) {
106  $messageDetails .= $notification->getText();
107  }
108 
109  $messageDetails .= '<p>';
110  $messageDetails .= __('Please see <a href="%1">documentation</a> for more details. ', $this->getInfoUrl());
111  $messageDetails .= __(
112  'Click here to go to <a href="%1">Tax Configuration</a> and change your settings.',
113  $this->getManageUrl()
114  );
115  $messageDetails .= '</p>';
116 
117  return $messageDetails;
118  }
119 
126  public function getSeverity()
127  {
129  }
130 
136  public function getInfoUrl()
137  {
138  return $this->taxConfig->getInfoUrl();
139  }
140 
146  public function getManageUrl()
147  {
148  return $this->urlBuilder->getUrl('adminhtml/system_config/edit/section/tax');
149  }
150 
163  public function checkDisplaySettings($store = null)
164  {
165  if ($this->taxConfig->getAlgorithm($store) == \Magento\Tax\Model\Calculation::CALC_UNIT_BASE) {
166  return true;
167  }
168  return $this->taxConfig->getPriceDisplayType($store) != \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH
169  && $this->taxConfig->getShippingPriceDisplayType($store) != \Magento\Tax\Model\Config::DISPLAY_TYPE_BOTH
170  && !$this->taxConfig->displayCartPricesBoth($store)
171  && !$this->taxConfig->displayCartSubtotalBoth($store)
172  && !$this->taxConfig->displayCartShippingBoth($store)
173  && !$this->taxConfig->displaySalesPricesBoth($store)
174  && !$this->taxConfig->displaySalesSubtotalBoth($store)
175  && !$this->taxConfig->displaySalesShippingBoth($store);
176  }
177 
190  public function checkDiscountSettings($store = null)
191  {
192  return $this->taxConfig->applyTaxAfterDiscount($store);
193  }
194 
202  public function getIgnoreTaxNotificationUrl($section)
203  {
204  return $this->urlBuilder->getUrl('tax/tax/ignoreTaxNotification', ['section' => $section]);
205  }
206 
216  {
217  $storeNames = [];
218  $storeCollection = $this->storeManager->getStores(true);
219  foreach ($storeCollection as $store) {
220  if (!$this->checkDisplaySettings($store)) {
221  $website = $store->getWebsite();
222  $storeNames[] = $website->getName() . '(' . $store->getName() . ')';
223  }
224  }
225  return $storeNames;
226  }
227 
237  {
238  $storeNames = [];
239  $storeCollection = $this->storeManager->getStores(true);
240  foreach ($storeCollection as $store) {
241  if (!$this->checkDiscountSettings($store)) {
242  $website = $store->getWebsite();
243  $storeNames[] = $website->getName() . '(' . $store->getName() . ')';
244  }
245  }
246  return $storeNames;
247  }
248 }
__()
Definition: __.php:13
__construct(\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Tax\Model\Config $taxConfig, $notifications=[])