Skip to content

Commit 6d81c4a

Browse files
committed
Merge remote-tracking branch 'origin/MC-20193' into 2.3-develop-pr78
2 parents d95a654 + 37d74d6 commit 6d81c4a

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

app/code/Magento/Quote/Observer/SubmitObserver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Psr\Log\LoggerInterface;
1515

1616
/**
17-
* Class SubmitObserver
17+
* Class responsive for sending order and invoice emails when it's created through storefront.
1818
*/
1919
class SubmitObserver implements ObserverInterface
2020
{
@@ -49,7 +49,7 @@ public function __construct(
4949
}
5050

5151
/**
52-
* Sends emails to customer.
52+
* Send order and invoice email.
5353
*
5454
* @param Observer $observer
5555
*

app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Sales\Model\Order\ShipmentFactory;
1717
use Magento\Sales\Model\Order\Invoice;
1818
use Magento\Sales\Model\Service\InvoiceService;
19+
use Magento\Sales\Helper\Data as SalesData;
1920

2021
/**
2122
* Save invoice controller.
@@ -56,28 +57,36 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
5657
*/
5758
private $invoiceService;
5859

60+
/**
61+
* @var SalesData
62+
*/
63+
private $salesData;
64+
5965
/**
6066
* @param Action\Context $context
6167
* @param Registry $registry
6268
* @param InvoiceSender $invoiceSender
6369
* @param ShipmentSender $shipmentSender
6470
* @param ShipmentFactory $shipmentFactory
6571
* @param InvoiceService $invoiceService
72+
* @param SalesData $salesData
6673
*/
6774
public function __construct(
6875
Action\Context $context,
6976
Registry $registry,
7077
InvoiceSender $invoiceSender,
7178
ShipmentSender $shipmentSender,
7279
ShipmentFactory $shipmentFactory,
73-
InvoiceService $invoiceService
80+
InvoiceService $invoiceService,
81+
SalesData $salesData = null
7482
) {
7583
$this->registry = $registry;
7684
$this->invoiceSender = $invoiceSender;
7785
$this->shipmentSender = $shipmentSender;
7886
$this->shipmentFactory = $shipmentFactory;
7987
$this->invoiceService = $invoiceService;
8088
parent::__construct($context);
89+
$this->salesData = $salesData ?? $this->_objectManager->get(SalesData::class);
8190
}
8291

8392
/**
@@ -204,7 +213,7 @@ public function execute()
204213

205214
// send invoice/shipment emails
206215
try {
207-
if (!empty($data['send_email'])) {
216+
if (!empty($data['send_email']) || $this->salesData->canSendNewInvoiceEmail()) {
208217
$this->invoiceSender->send($invoice);
209218
}
210219
} catch (\Exception $e) {
@@ -213,7 +222,7 @@ public function execute()
213222
}
214223
if ($shipment) {
215224
try {
216-
if (!empty($data['send_email'])) {
225+
if (!empty($data['send_email']) || $this->salesData->canSendNewShipmentEmail()) {
217226
$this->shipmentSender->send($shipment);
218227
}
219228
} catch (\Exception $e) {

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SaveTest extends AbstractInvoiceControllerTest
2828
*/
2929
public function testSendEmailOnInvoiceSave(): void
3030
{
31-
$order = $this->prepareRequest(['invoice' => ['send_email' => true]]);
31+
$order = $this->prepareRequest();
3232
$this->dispatch('backend/sales/order_invoice/save');
3333

3434
$this->assertSessionMessages(

0 commit comments

Comments
 (0)