diff --git a/Model/Customer/Notifier/MailSender.php b/Model/Customer/Notifier/MailSender.php index c6abf047..a7e59dba 100644 --- a/Model/Customer/Notifier/MailSender.php +++ b/Model/Customer/Notifier/MailSender.php @@ -16,30 +16,42 @@ use Magento\Framework\Mail\Template\TransportBuilder; use Magento\Store\Model\StoreManagerInterface; use Opengento\Gdpr\Model\Notifier\AbstractMailSender; +use Psr\Log\LoggerInterface; final class MailSender extends AbstractMailSender implements SenderInterface { + /** + * @var LoggerInterface + */ + private LoggerInterface $logger; + /** * @var View */ private View $customerViewHelper; - private StoreManagerInterface $storeManager; + /** + * @var StoreManagerInterface + */ + private $storeManager; public function __construct( + LoggerInterface $logger, View $customerViewHelper, TransportBuilder $transportBuilder, ScopeConfigInterface $scopeConfig, StoreManagerInterface $storeManager, array $configPaths ) { + $this->logger = $logger; $this->customerViewHelper = $customerViewHelper; $this->storeManager = $storeManager; parent::__construct($transportBuilder, $scopeConfig, $configPaths); } /** - * @inheritdoc + * @param CustomerInterface $customer + * @return void * @throws LocalizedException * @throws MailException * @throws NoSuchEntityException @@ -50,8 +62,16 @@ public function send(CustomerInterface $customer): void $vars = [ 'customer' => $customer, 'store' => $this->storeManager->getStore($customer->getStoreId()), + 'customer_data' => [ + 'customer_name' => $this->customerViewHelper->getCustomerName($customer), + ], ]; - - $this->sendMail($customer->getEmail(), $this->customerViewHelper->getCustomerName($customer), $storeId, $vars); + + try { + $this->sendMail($customer->getEmail(), $this->customerViewHelper->getCustomerName($customer), $storeId, $vars); + $this->logger->debug(__('GDPR Email Success')); + } catch (MailException $exc) { + $this->logger->error(__('GDPR Email Error: %1', $exc->getMessage())); + } } } diff --git a/Model/Order/Notifier/MailSender.php b/Model/Order/Notifier/MailSender.php index eb94f62e..ca3c94df 100644 --- a/Model/Order/Notifier/MailSender.php +++ b/Model/Order/Notifier/MailSender.php @@ -14,17 +14,28 @@ use Magento\Sales\Api\Data\OrderInterface; use Magento\Store\Model\StoreManagerInterface; use Opengento\Gdpr\Model\Notifier\AbstractMailSender; +use Psr\Log\LoggerInterface; final class MailSender extends AbstractMailSender implements SenderInterface { + /** + * @var LoggerInterface + */ + private LoggerInterface $logger; + + /** + * @var StoreManagerInterface + */ private StoreManagerInterface $storeManager; public function __construct( + LoggerInterface $logger, TransportBuilder $transportBuilder, ScopeConfigInterface $scopeConfig, StoreManagerInterface $storeManager, array $configPaths ) { + $this->logger = $logger; $this->storeManager = $storeManager; parent::__construct($transportBuilder, $scopeConfig, $configPaths); } @@ -39,9 +50,19 @@ public function send(OrderInterface $order): void $storeId = $order->getStoreId() === null ? null : (int) $order->getStoreId(); $vars = [ 'order' => $order, + 'billing' => $order->getBillingAddress(), 'store' => $this->storeManager->getStore($order->getStoreId()), + 'customer_data' => [ + 'customer_name' => $order->getCustomerName(), + ], ]; - $this->sendMail($order->getCustomerEmail(), $order->getCustomerName(), $storeId, $vars); + try { + $this->sendMail($order->getCustomerEmail(), $order->getCustomerName(), $storeId, $vars); + $this->logger->debug(__('GDPR Email Success')); + } catch (MailException $exc) { + $this->logger->error(__('GDPR Email Error: %1', $exc->getMessage())); + } + } } diff --git a/view/frontend/email/erase_canceled.html b/view/frontend/email/erase_canceled.html index 915e67d5..39af4cf9 100644 --- a/view/frontend/email/erase_canceled.html +++ b/view/frontend/email/erase_canceled.html @@ -6,18 +6,25 @@ --> {{template config_path="design/email/header_template"}} - -
{{trans "%name," name=$customer.name}}
- -- {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. -
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+
{{trans "%name," name=$order.getBillingAddress().getName()}}
- -- {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. -
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+
{{trans "%name," name=$customer.name}}
- -- {{trans "We have received a request to erase the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. - {{trans 'You can cancel the erase whitin %delay hours by logging into your account.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} -
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} +{{trans 'You can cancel the erase whitin %delay hours by logging into your account.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+
{{trans "%name," name=$order.getBillingAddress().getName()}}
- -- {{trans "We have received a request to erase the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. - {{trans 'You can cancel the erase whitin %delay hours by logging into your account.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} -
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} +{{trans 'You can cancel the erase whitin %delay hours by logging into your account.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+
{{trans "%name," name=$customer.name}}
- -- {{trans "We have successfully erased the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. -
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} +{{trans 'You can cancel the erase whitin %delay hours by logging into your account.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+
{{trans "%name," name=$order.getBillingAddress().getName()}}
- -- {{trans "We have successfully erased the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. -
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} +{{trans 'You can cancel the erase whitin %delay hours by logging into your account.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+
{{trans "%name," name=$customer.name}}
- -- {{trans "We have received a request to export the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. -
- -{{trans "We will notify you when the export will be ready. The action will be available in your account."}}
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} +{{trans "We will notify you when the export will be ready. The action will be available in your account."}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+
{{trans "%name," name=$order.getBillingAddress().getName()}}
- -- {{trans "We have received a request to export the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. -
- -{{trans "We will notify you when the export will be ready. The action will be available in your account."}}
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} +{{trans "We will notify you when the export will be ready. The action will be available in your account."}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+
{{trans "%name," name=$customer.name}}
- -- {{trans "We have received a request to export the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. -
- -{{trans "The export of you personal data is ready. The action is now available in your account."}}
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} +{{trans "The export of you personal data is ready. The action is now available in your account."}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+
{{trans "%name," name=$order.getBillingAddress().getName()}}
- -- {{trans "We have received a request to export the information associated with your account at %store_name." store_name=$store.getFrontendName()}} - {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. -
- -{{trans "The export of you personal data is ready. The action is now available in your account."}}
- -{{trans "Thanks,
%store_name" store_name=$store.getFrontendName() |raw}}
+ {{trans "%name," name=$customer_data.customer_name}} + |
+
+ {{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}} +{{trans "The export of you personal data is ready. The action is now available in your account."}} + |
+
+ {{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}. + |
+