Skip to content

Commit

Permalink
Merge pull request #121 from elisei/master
Browse files Browse the repository at this point in the history
Fix #118 and #120
  • Loading branch information
thomas-kl1 authored Apr 29, 2022
2 parents 0f56e53 + 88fdebb commit 4ef6b09
Show file tree
Hide file tree
Showing 12 changed files with 236 additions and 127 deletions.
28 changes: 24 additions & 4 deletions Model/Customer/Notifier/MailSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()));
}
}
}
23 changes: 22 additions & 1 deletion Model/Order/Notifier/MailSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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()));
}

}
}
29 changes: 18 additions & 11 deletions view/frontend/email/erase_canceled.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@
-->
<!--@subject {{trans "Cancellation of the erase of your %store_name information" store_name=$store.getFrontendName()}} @-->
<!--@vars {
"var customer.name":"Customer Name",
"var customer_data.customer_name":"Customer Name"
} @-->

{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "%name," name=$customer.name}}</p>

<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
</p>

<p>{{trans "Thanks,<br>%store_name" store_name=$store.getFrontendName() |raw}}</p>

<table border="0" cellspacing="0" width="100%" cellpadding="0">
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$customer_data.customer_name}}</p>
</td>
</tr>
<tr class="email-summary">
<td>
<p>{{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
</td>
</tr>
<tr class="help-info">
<td>
<p>{{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.</p>
</td>
</tr>
</table>
{{template config_path="design/email/footer_template"}}
30 changes: 18 additions & 12 deletions view/frontend/email/erase_canceled_guest.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@
-->
<!--@subject {{trans "Cancellation of the erase of your %store_name information" store_name=$store.getFrontendName()}} @-->
<!--@vars {
"var customer.name":"Customer Name",
"var customer_data.customer_name":"Guest Customer Name"
} @-->

{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "%name," name=$order.getBillingAddress().getName()}}</p>

<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
</p>

<p>{{trans "Thanks,<br>%store_name" store_name=$store.getFrontendName() |raw}}</p>

{{template config_path="design/email/footer_template"}}
<table border="0" cellspacing="0" width="100%" cellpadding="0">
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$customer_data.customer_name}}</p>
</td>
</tr>
<tr class="email-summary">
<td>
<p>{{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
</td>
</tr>
<tr class="help-info">
<td>
<p>{{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.</p>
</td>
</tr>
</table>
31 changes: 19 additions & 12 deletions view/frontend/email/erase_pending.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@
-->
<!--@subject {{trans "Erase your %store_name information" store_name=$store.getFrontendName()}} @-->
<!--@vars {
"var customer.name":"Customer Name",
"var customer_data.customer_name":"Customer Name"
} @-->

{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "%name," name=$customer.name}}</p>

<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
{{trans 'You can cancel the erase whitin %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}
</p>

<p>{{trans "Thanks,<br>%store_name" store_name=$store.getFrontendName() |raw}}</p>

<table border="0" cellspacing="0" width="100%" cellpadding="0">
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$customer_data.customer_name}}</p>
</td>
</tr>
<tr class="email-summary">
<td>
<p>{{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
<p>{{trans 'You can cancel the erase whitin %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
</td>
</tr>
<tr class="help-info">
<td>
<p>{{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.</p>
</td>
</tr>
</table>
{{template config_path="design/email/footer_template"}}
31 changes: 19 additions & 12 deletions view/frontend/email/erase_pending_guest.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,26 @@
-->
<!--@subject {{trans "Erase your %store_name information" store_name=$store.getFrontendName()}} @-->
<!--@vars {
"var customer.name":"Customer Name",
"var customer_data.customer_name":"Guest Customer Name"
} @-->

{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "%name," name=$order.getBillingAddress().getName()}}</p>

<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
{{trans 'You can cancel the erase whitin %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}
</p>

<p>{{trans "Thanks,<br>%store_name" store_name=$store.getFrontendName() |raw}}</p>

<table border="0" cellspacing="0" width="100%" cellpadding="0">
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$customer_data.customer_name}}</p>
</td>
</tr>
<tr class="email-summary">
<td>
<p>{{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
<p>{{trans 'You can cancel the erase whitin %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
</td>
</tr>
<tr class="help-info">
<td>
<p>{{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.</p>
</td>
</tr>
</table>
{{template config_path="design/email/footer_template"}}
30 changes: 19 additions & 11 deletions view/frontend/email/erase_succeeded.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@
-->
<!--@subject {{trans "Erasure of your %store_name information" store_name=$store.getFrontendName()}} @-->
<!--@vars {
"var customer.name":"Customer Name",
"var customer_data.customer_name":"Customer Name"
} @-->

{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "%name," name=$customer.name}}</p>

<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
</p>

<p>{{trans "Thanks,<br>%store_name" store_name=$store.getFrontendName() |raw}}</p>

<table border="0" cellspacing="0" width="100%" cellpadding="0">
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$customer_data.customer_name}}</p>
</td>
</tr>
<tr class="email-summary">
<td>
<p>{{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
<p>{{trans 'You can cancel the erase whitin %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
</td>
</tr>
<tr class="help-info">
<td>
<p>{{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.</p>
</td>
</tr>
</table>
{{template config_path="design/email/footer_template"}}
30 changes: 19 additions & 11 deletions view/frontend/email/erase_succeeded_guest.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@
-->
<!--@subject {{trans "Erasure of your %store_name information" store_name=$store.getFrontendName()}} @-->
<!--@vars {
"var customer.name":"Customer Name",
"var customer_data.customer_name":"Guest Customer Name"
} @-->

{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "%name," name=$order.getBillingAddress().getName()}}</p>

<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
</p>

<p>{{trans "Thanks,<br>%store_name" store_name=$store.getFrontendName() |raw}}</p>

<table border="0" cellspacing="0" width="100%" cellpadding="0">
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$customer_data.customer_name}}</p>
</td>
</tr>
<tr class="email-summary">
<td>
<p>{{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
<p>{{trans 'You can cancel the erase whitin %delay hours by <a href="%account_url">logging into your account</a>.' account_url=$this.getUrl($store,'customer/account/',[_nosid:1]) |raw}}</p>
</td>
</tr>
<tr class="help-info">
<td>
<p>{{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.</p>
</td>
</tr>
</table>
{{template config_path="design/email/footer_template"}}
34 changes: 20 additions & 14 deletions view/frontend/email/export_pending.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@
-->
<!--@subject {{trans "Export your %store_name information" store_name=$store.getFrontendName()}} @-->
<!--@vars {
"var customer.name":"Customer Name",
"var customer_data.customer_name":"Customer Name"
} @-->

{{template config_path="design/email/header_template"}}

<p class="greeting">{{trans "%name," name=$customer.name}}</p>

<p>
{{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 <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.
</p>

<p>{{trans "We will notify you when the export will be ready. The action will be available in your account."}}</p>

<p>{{trans "Thanks,<br>%store_name" store_name=$store.getFrontendName() |raw}}</p>

{{template config_path="design/email/footer_template"}}
<table border="0" cellspacing="0" width="100%" cellpadding="0">
<tr class="email-intro">
<td>
<p class="greeting">{{trans "%name," name=$customer_data.customer_name}}</p>
</td>
</tr>
<tr class="email-summary">
<td>
<p>{{trans "We have received a request to cancel the erasure of the information associated with your account at %store_name." store_name=$store.getFrontendName()}}</p>
<p>{{trans "We will notify you when the export will be ready. The action will be available in your account."}}</p>
</td>
</tr>
<tr class="help-info">
<td>
<p>{{trans 'If you have not authorized this action, please contact us immediately at <a href="mailto:%store_email">%store_email</a>' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at <a href="tel:%store_phone">%store_phone</a>' store_phone=$store_phone |raw}}{{/depend}}.</p>
</td>
</tr>
</table>
{{template config_path="design/email/footer_template"}}
Loading

0 comments on commit 4ef6b09

Please sign in to comment.