Skip to content

Commit

Permalink
Fixed order email confirmation mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
Volodymyr Klymenko committed Mar 6, 2020
1 parent 61976bc commit 2bcc196
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
14 changes: 0 additions & 14 deletions Model/TransactionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ private function processReservedTransaction(QuoteInterface $vippsQuote, Transact
$vippsQuote->setStatus(QuoteInterface::STATUS_RESERVED);
$this->quoteManagement->save($vippsQuote);

$this->sendOrderConfirmation($order);

return $order;
}

Expand Down Expand Up @@ -421,18 +419,6 @@ private function authorize(OrderInterface $order, Transaction $transaction)
$this->orderRepository->save($order);
}

/**
* Send order conformation email if not sent
*
* @param Order|OrderInterface $order
*/
private function sendOrderConfirmation($order)
{
if ($order->getCanSendNewEmailFlag() && !$order->getEmailSent()) {
$this->orderManagement->notify($order->getEntityId());
}
}

/**
* @param $lockName
*
Expand Down
27 changes: 14 additions & 13 deletions Observer/CheckoutSubmitAllAfter.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,21 @@ public function __construct(
*/
public function execute(Observer $observer)
{
try {
/** @var OrderInterface $order */
$order = $observer->getData('order');
/** @var OrderInterface $order */
$order = $observer->getData('order');
if ('vipps' == $order->getPayment()->getMethod()) {
try {
// send order placed email
$this->notify($order);

// send order placed email
$this->notify($order);

// updated vipps quote
$vippsQuote = $this->quoteRepository->loadByOrderId($order->getIncrementId());
$vippsQuote->setOrderId((int)$order->getEntityId());
$vippsQuote->setStatus(QuoteInterface::STATUS_PENDING);
$this->quoteRepository->save($vippsQuote);
} catch (\Throwable $t) {
$this->logger->error($t->getMessage());
// updated vipps quote
$vippsQuote = $this->quoteRepository->loadByOrderId($order->getIncrementId());
$vippsQuote->setOrderId((int)$order->getEntityId());
$vippsQuote->setStatus(QuoteInterface::STATUS_PENDING);
$this->quoteRepository->save($vippsQuote);
} catch (\Throwable $t) {
$this->logger->error($t->getMessage());
}
}
}

Expand Down

0 comments on commit 2bcc196

Please sign in to comment.