Skip to content

Commit

Permalink
PLUG-105: Fix shipping method being occasionally dropped when re-savi…
Browse files Browse the repository at this point in the history
…ng quotes
  • Loading branch information
lighe authored May 15, 2024
2 parents 5bd77fb + c796c20 commit 2f3b6af
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v1.0.10] - 2024-05-07

### Fixed

- Fix shipping method being dropped in some cases

## [v1.0.10] - 2024-04-12

### Changed
Expand Down
13 changes: 9 additions & 4 deletions Service/Order/ProcessReturn.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\Order;
use Magento\Quote\Api\CartManagementInterface;
use TrueLayer\Connect\Api\Log\RepositoryInterface as LogRepository;
use TrueLayer\Connect\Api\Transaction\RepositoryInterface as TransactionRepository;
use TrueLayer\Connect\Service\Api\GetClient;
Expand Down Expand Up @@ -58,6 +59,10 @@ class ProcessReturn
* @var LogRepository
*/
private $logger;
/**
* @var CartManagementInterface
*/
private $cartManagement;

/**
* ProcessReturn constructor.
Expand All @@ -76,6 +81,7 @@ public function __construct(
CartRepositoryInterface $quoteRepository,
OrderInterface $orderInterface,
OrderRepositoryInterface $orderRepository,
CartManagementInterface $cartManagement,
TransactionRepository $transactionRepository,
LogRepository $logger
) {
Expand All @@ -84,6 +90,7 @@ public function __construct(
$this->quoteRepository = $quoteRepository;
$this->orderInterface = $orderInterface;
$this->orderRepository = $orderRepository;
$this->cartManagement = $cartManagement;
$this->transactionRepository = $transactionRepository;
$this->logger = $logger;
}
Expand Down Expand Up @@ -113,9 +120,6 @@ public function execute(string $transactionId): array
if (!$order->getEntityId()) {
if ($transactionStatus == 'settled' || $transactionStatus == 'executed') {
return ['success' => false, 'status' => $transactionStatus];
} else {
$quote->setIsActive(true);
$this->quoteRepository->save($quote);
}
}

Expand All @@ -142,7 +146,7 @@ public function execute(string $transactionId): array
/**
* @param CartInterface $quote
* @param Order $order
* @return void
* @throws \Magento\Framework\Exception\CouldNotSaveException
*/
private function updateCheckoutSession(CartInterface $quote, Order $order): void
{
Expand All @@ -153,6 +157,7 @@ private function updateCheckoutSession(CartInterface $quote, Order $order): void
try {
$activeQuote = $this->quoteRepository->getActiveForCustomer($customerId);
$this->quoteRepository->delete($activeQuote);
$this->cartManagement->createEmptyCartForCustomer($customerId);
} catch (NoSuchEntityException $e) {
$this->logger->addErrorLog('Remove customer quote', $e->getMessage());
}
Expand Down
1 change: 1 addition & 0 deletions Service/Order/ProcessWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ private function prepareQuote(CartInterface $quote, string $userId): CartInterfa

$quote->setCustomerIsGuest($quote->getCustomerId() == null);
$quote->setIsActive(true);
$quote->getShippingAddress()->setCollectShippingRates(false);
$this->quoteRepository->save($quote);
return $quote;
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "truelayer/magento2",
"description": "TrueLayer extension for Magento 2",
"type": "magento2-module",
"version": "1.0.10",
"version": "1.0.11",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<default>
<payment>
<truelayer>
<version>1.0.10</version>
<version>1.0.11</version>
<model>TrueLayerFacade</model>
<title>TrueLayer</title>
<description>Pay using TrueLayer</description>
Expand Down

0 comments on commit 2f3b6af

Please sign in to comment.