-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API] Order confirmation email sending #11754
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7f95827
[API] Order confirmation email sending
lchrusciel ffb19b6
[Core] Extract mailer sender from ShopBundle
lchrusciel 3c98df3
[Core] Extract order confirmation templates to core
lchrusciel 866767f
[Core] Sending order confiramtion email from core
lchrusciel 78223c1
[Core] Test order confirmation mailing
lchrusciel 6598363
fix composer.json api platform, tests for api mailing added
SirDomin 4e419ae
build fix
SirDomin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' %} | ||
SirDomin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{% 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.