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 '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}}.

+
{{template config_path="design/email/footer_template"}} diff --git a/view/frontend/email/erase_canceled_guest.html b/view/frontend/email/erase_canceled_guest.html index cde85b48..0f0bb51e 100644 --- a/view/frontend/email/erase_canceled_guest.html +++ b/view/frontend/email/erase_canceled_guest.html @@ -6,18 +6,24 @@ --> {{template config_path="design/email/header_template"}} - -

{{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}}

- -{{template config_path="design/email/footer_template"}} + + + + + + + + + + +
+

{{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}}.

+
\ No newline at end of file diff --git a/view/frontend/email/erase_pending.html b/view/frontend/email/erase_pending.html index 4896ddd8..66afac5a 100644 --- a/view/frontend/email/erase_pending.html +++ b/view/frontend/email/erase_pending.html @@ -6,19 +6,26 @@ --> {{template config_path="design/email/header_template"}} - -

{{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 '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}}.

+
{{template config_path="design/email/footer_template"}} diff --git a/view/frontend/email/erase_pending_guest.html b/view/frontend/email/erase_pending_guest.html index 411d78e3..5b4e8236 100644 --- a/view/frontend/email/erase_pending_guest.html +++ b/view/frontend/email/erase_pending_guest.html @@ -6,19 +6,26 @@ --> {{template config_path="design/email/header_template"}} - -

{{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 '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}}.

+
{{template config_path="design/email/footer_template"}} diff --git a/view/frontend/email/erase_succeeded.html b/view/frontend/email/erase_succeeded.html index 454b360d..bd1f805e 100644 --- a/view/frontend/email/erase_succeeded.html +++ b/view/frontend/email/erase_succeeded.html @@ -6,18 +6,26 @@ --> {{template config_path="design/email/header_template"}} - -

{{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 '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}}.

+
{{template config_path="design/email/footer_template"}} diff --git a/view/frontend/email/erase_succeeded_guest.html b/view/frontend/email/erase_succeeded_guest.html index 85eb3fb9..cfc6e3d8 100644 --- a/view/frontend/email/erase_succeeded_guest.html +++ b/view/frontend/email/erase_succeeded_guest.html @@ -6,18 +6,26 @@ --> {{template config_path="design/email/header_template"}} - -

{{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 '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}}.

+
{{template config_path="design/email/footer_template"}} diff --git a/view/frontend/email/export_pending.html b/view/frontend/email/export_pending.html index ecebd4b8..a5b86606 100644 --- a/view/frontend/email/export_pending.html +++ b/view/frontend/email/export_pending.html @@ -6,20 +6,26 @@ --> {{template config_path="design/email/header_template"}} - -

{{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}}

- -{{template config_path="design/email/footer_template"}} + + + + + + + + + + +
+

{{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}}.

+
+{{template config_path="design/email/footer_template"}} \ No newline at end of file diff --git a/view/frontend/email/export_pending_guest.html b/view/frontend/email/export_pending_guest.html index 30c80df8..c5f8ae3b 100644 --- a/view/frontend/email/export_pending_guest.html +++ b/view/frontend/email/export_pending_guest.html @@ -6,20 +6,26 @@ --> {{template config_path="design/email/header_template"}} - -

{{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 '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}}.

+
{{template config_path="design/email/footer_template"}} diff --git a/view/frontend/email/export_ready.html b/view/frontend/email/export_ready.html index fe1f0bef..44402ac7 100644 --- a/view/frontend/email/export_ready.html +++ b/view/frontend/email/export_ready.html @@ -6,20 +6,27 @@ --> {{template config_path="design/email/header_template"}} - -

{{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 '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}}.

+
{{template config_path="design/email/footer_template"}} + diff --git a/view/frontend/email/export_ready_guest.html b/view/frontend/email/export_ready_guest.html index 7269a28f..5616aafc 100644 --- a/view/frontend/email/export_ready_guest.html +++ b/view/frontend/email/export_ready_guest.html @@ -6,20 +6,26 @@ --> {{template config_path="design/email/header_template"}} - -

{{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 '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}}.

+
{{template config_path="design/email/footer_template"}}