18 private $storeManager;
35 private $storesWithInvalidSettings;
46 \
Magento\Framework\UrlInterface $urlBuilder,
50 $this->urlBuilder = $urlBuilder;
51 $this->taxConfig = $taxConfig;
60 return 'TAX_NOTIFICATION_DISCOUNT_ERRORS';
68 if (!$this->taxConfig->isWrongDiscountSettingsIgnored() && $this->getStoresWithWrongSettings()) {
81 if (!empty($this->getStoresWithWrongSettings()) && !$this->taxConfig->isWrongDiscountSettingsIgnored()) {
82 $messageDetails .=
'<strong>';
83 $messageDetails .=
__(
'With customer tax applied “Before Discount”,' 84 .
' the final discount calculation may not match customers’ expectations. ');
85 $messageDetails .=
'</strong><p>';
86 $messageDetails .=
__(
'Store(s) affected: ');
87 $messageDetails .= implode(
', ', $this->getStoresWithWrongSettings());
88 $messageDetails .=
'</p><p>';
89 $messageDetails .=
__(
90 'Click on the link to <a href="%1">ignore this notification</a>',
91 $this->urlBuilder->getUrl(
'tax/tax/ignoreTaxNotification', [
'section' =>
'discount'])
93 $messageDetails .=
"</p>";
96 return $messageDetails;
118 private function checkSettings(
$store =
null)
120 return $this->taxConfig->applyTaxAfterDiscount(
$store);
129 private function getStoresWithWrongSettings()
131 if (
null !== $this->storesWithInvalidSettings) {
132 return $this->storesWithInvalidSettings;
134 $this->storesWithInvalidSettings = [];
135 $storeCollection = $this->storeManager->getStores(
true);
136 foreach ($storeCollection as
$store) {
137 if (!$this->checkSettings(
$store)) {
139 $this->storesWithInvalidSettings[] =
$website->getName() .
' (' .
$store->getName() .
')';
142 return $this->storesWithInvalidSettings;
__construct(\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Tax\Model\Config $taxConfig)