-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated method used to determine whether emails are sent on creation …
…of invoices, creditmemos and shipments from the admin page. Now takes into account global "enabled" setting and the checkbox on creation page. Updated Unit and Integration tests to suit.
- Loading branch information
Graham Wharton
committed
Nov 17, 2020
1 parent
26acabe
commit e0d8149
Showing
8 changed files
with
439 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface; | ||
use Magento\Backend\App\Action; | ||
use Magento\Sales\Helper\Data as SalesData; | ||
use Magento\Sales\Model\Order; | ||
use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender; | ||
|
||
|
@@ -34,21 +35,30 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac | |
*/ | ||
protected $resultForwardFactory; | ||
|
||
/** | ||
* @var SalesData | ||
*/ | ||
private $salesData; | ||
|
||
/** | ||
* @param Action\Context $context | ||
* @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader | ||
* @param CreditmemoSender $creditmemoSender | ||
* @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory | ||
* @param SalesData $salesData | ||
*/ | ||
public function __construct( | ||
Action\Context $context, | ||
\Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader, | ||
CreditmemoSender $creditmemoSender, | ||
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory | ||
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, | ||
SalesData $salesData = null | ||
) { | ||
$this->creditmemoLoader = $creditmemoLoader; | ||
$this->creditmemoSender = $creditmemoSender; | ||
$this->resultForwardFactory = $resultForwardFactory; | ||
$this->salesData = $salesData ?: \Magento\Framework\App\ObjectManager::getInstance() | ||
->get(SalesData::class); | ||
parent::__construct($context); | ||
} | ||
|
||
|
@@ -108,7 +118,7 @@ public function execute() | |
$doOffline = isset($data['do_offline']) ? (bool)$data['do_offline'] : false; | ||
$creditmemoManagement->refund($creditmemo, $doOffline); | ||
|
||
if (!empty($data['send_email'])) { | ||
if (!empty($data['send_email']) && $this->salesData->canSendNewCreditMemoEmail()) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gwharton
Contributor
|
||
$this->creditmemoSender->send($creditmemo); | ||
} | ||
|
||
|
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
Oops, something went wrong.
@gwharton The method
$this->salesData->canSendNewCreditMemoEmail()
is not receiving the storeCode of where the order was placed. It's now checking the default setting instead of the setting of where the order was placed.So if
sales_email/shipment/enabled
is disabled by default, but enabled for a specific store this email is never send.The solution would be: