-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #11754 [API] Order confirmation email sending (lchrusciel, Si…
…rDomin) This PR was merged into the 1.9-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT <!-- - Bug fixes must be submitted against the 1.7 branch (the lowest possible) - Features and deprecations must be submitted against the master branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> This PR introduce mailing refactor, which should be continued in the future. Bigger description and ADR in progress. Commits ------- 7f95827 [API] Order confirmation email sending ffb19b6 [Core] Extract mailer sender from ShopBundle 3c98df3 [Core] Extract order confirmation templates to core 866767f [Core] Sending order confiramtion email from core 78223c1 [Core] Test order confirmation mailing 6598363 fix composer.json api platform, tests for api mailing added 4e419ae build fix
- Loading branch information
Showing
26 changed files
with
581 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 1 addition & 28 deletions
29
src/Sylius/Bundle/AdminBundle/Resources/views/Email/layout.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1 @@ | ||
{% block body %} | ||
{% autoescape false %} | ||
{% set logo = channel.hostname is not null ? 'http://' ~ channel.hostname ~ asset('assets/admin/img/logo.png') : absolute_url(asset('assets/admin/img/logo.png')) %} | ||
|
||
<div style="font-family: sans-serif; background: #eee; padding-top: 30px; padding-bottom: 30px; font-size: 16px; color: #333; line-height: 1.5"> | ||
<div style="max-width: 600px; margin: 20px auto;"> | ||
<div style="margin-bottom: 30px; text-align: center;"> | ||
{% if sylius_bundle_loaded_checker('SyliusShopBundle') %} | ||
{% set url = channel.hostname is not null ? 'http://' ~ channel.hostname ~ path('sylius_shop_homepage', {'_locale': localeCode}) : url('sylius_shop_homepage', {'_locale': localeCode}) %} | ||
<a href="{{ url|raw }}"> | ||
<img src="{{ logo }}" alt="Sylius" style="width: 170px"> | ||
</a> | ||
{% else %} | ||
<img src="{{ logo }}" alt="Sylius" style="width: 170px"> | ||
{% endif %} | ||
</div> | ||
|
||
<div style="background: #fff; padding: 40px 30px;"> | ||
{% block content %}{% endblock %} | ||
</div> | ||
|
||
<div style="text-align: center; padding: 20px 0;"> | ||
<a href="https://sylius.com" target="_blank" style="color: #1abb9c; text-decoration: none;">sylius.com</a> | ||
</div> | ||
</div> | ||
</div> | ||
{% endautoescape %} | ||
{% endblock %} | ||
{% extends '@SyliusCore/Email/layout.html.twig' %} |
25 changes: 3 additions & 22 deletions
25
src/Sylius/Bundle/AdminBundle/Resources/views/Email/orderConfirmation.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,10 @@ | ||
{% deprecated 'The "@SyliusAdmin/Email/orderConfirmation.html.twig" template is deprecated since Sylius 1.8 and will be removed in Sylius 2.0, use "@SyliusCore/Email/layout.html.twig" instead.' %} | ||
{% extends '@SyliusAdmin/Email/layout.html.twig' %} | ||
|
||
{% block subject %} | ||
{{ 'sylius.email.order_confirmation.subject'|trans({}, null, localeCode) }} | ||
{% include '@SyliusCore/Email/Blocks/OrderConfirmation/_subject.html.twig' %} | ||
{% endblock %} | ||
|
||
{% block content %} | ||
{% set url = channel.hostname is not null ? 'http://' ~ channel.hostname ~ path('sylius_shop_order_show', {'tokenValue': order.tokenValue, '_locale': localeCode}) : url('sylius_shop_order_show', {'tokenValue': order.tokenValue, '_locale': localeCode}) %} | ||
|
||
<div style="text-align: center; margin-bottom: 30px;"> | ||
{{ 'sylius.email.order_confirmation.your_order_number'|trans({}, null, localeCode) }} | ||
<div style="margin: 10px 0;"> | ||
<span style="border: 1px solid #eee; padding: 10px; color: #1abb9c; font-size: 28px;"> | ||
{{ order.number }} | ||
</span> | ||
</div> | ||
{{ 'sylius.email.order_confirmation.has_been_successfully_placed'|trans({}, null, localeCode) }} | ||
</div> | ||
|
||
<div style="text-align: center; margin-bottom: 30px;"> | ||
<a href="{{ url|raw }}" style="display: inline-block; text-align: center; background: #1abb9c; padding: 18px 28px; color: #fff; text-decoration: none; border-radius: 3px;"> | ||
{{ 'sylius.email.order_confirmation.view_order_or_change_payment_method'|trans({}, null, localeCode) }} | ||
</a> | ||
</div> | ||
|
||
<div style="text-align: center;"> | ||
{{ 'sylius.email.order_confirmation.thank_you'|trans({}, null, localeCode) }} | ||
</div> | ||
{% include '@SyliusCore/Email/Blocks/OrderConfirmation/_content.html.twig' %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\CoreBundle\Mailer; | ||
|
||
use Sylius\Component\Core\Model\CustomerInterface; | ||
use Sylius\Component\Core\Model\OrderInterface; | ||
use Sylius\Component\Mailer\Sender\SenderInterface; | ||
|
||
final class OrderEmailManager implements OrderEmailManagerInterface | ||
{ | ||
/** @var SenderInterface */ | ||
private $emailSender; | ||
|
||
public function __construct(SenderInterface $emailSender) | ||
{ | ||
$this->emailSender = $emailSender; | ||
} | ||
|
||
public function sendConfirmationEmail(OrderInterface $order): void | ||
{ | ||
/** @var CustomerInterface $customer */ | ||
$customer = $order->getCustomer(); | ||
|
||
$this->emailSender->send( | ||
Emails::ORDER_CONFIRMATION, | ||
[$customer->getEmail()], | ||
[ | ||
'order' => $order, | ||
'channel' => $order->getChannel(), | ||
'localeCode' => $order->getLocaleCode(), | ||
] | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/Sylius/Bundle/CoreBundle/Mailer/OrderEmailManagerInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\CoreBundle\Mailer; | ||
|
||
use Sylius\Component\Core\Model\OrderInterface; | ||
|
||
interface OrderEmailManagerInterface | ||
{ | ||
public function sendConfirmationEmail(OrderInterface $order): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ylius/Bundle/CoreBundle/Resources/views/Email/Blocks/OrderConfirmation/_content.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div style="text-align: center; margin-bottom: 30px;"> | ||
{{ 'sylius.email.order_confirmation.your_order_number'|trans({}, null, localeCode) }} | ||
<div style="margin: 10px 0;"> | ||
<span style="border: 1px solid #eee; padding: 10px; color: #1abb9c; font-size: 28px;"> | ||
{{ order.number }} | ||
</span> | ||
</div> | ||
{{ 'sylius.email.order_confirmation.has_been_successfully_placed'|trans({}, null, localeCode) }} | ||
</div> | ||
|
||
{% if sylius_bundle_loaded_checker('SyliusShopBundle') %} | ||
{% set url = channel.hostname is not null ? 'http://' ~ channel.hostname ~ path('sylius_shop_order_show', {'tokenValue': order.tokenValue, '_locale': localeCode}) : url('sylius_shop_order_show', {'tokenValue': order.tokenValue, '_locale': localeCode}) %} | ||
|
||
<div style="text-align: center; margin-bottom: 30px;"> | ||
<a href="{{ url|raw }}" style="display: inline-block; text-align: center; background: #1abb9c; padding: 18px 28px; color: #fff; text-decoration: none; border-radius: 3px;"> | ||
{{ 'sylius.email.order_confirmation.view_order_or_change_payment_method'|trans({}, null, localeCode) }} | ||
</a> | ||
</div> | ||
{% endif %} | ||
|
||
<div style="text-align: center;"> | ||
{{ 'sylius.email.order_confirmation.thank_you'|trans({}, null, localeCode) }} | ||
</div> |
1 change: 1 addition & 0 deletions
1
...ylius/Bundle/CoreBundle/Resources/views/Email/Blocks/OrderConfirmation/_subject.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ 'sylius.email.order_confirmation.subject'|trans({}, null, localeCode) }} |
Oops, something went wrong.