-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathPatch-Klarna_Kco_v3-already-exist-order-check-fix.patch
58 lines (54 loc) · 2.27 KB
/
Patch-Klarna_Kco_v3-already-exist-order-check-fix.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--- Model/Order/Order.php 2025-02-12 09:43:12
+++ Model/Order/Order.php 2025-03-25 17:14:49
@@ -105,6 +105,10 @@
* @var Checkout
*/
private Checkout $checkoutConfiguration;
+ /**
+ * @var \Magento\Sales\Model\OrderFactory
+ */
+ private $orderFactory;
/**
* @param KcoSession $kcoSession
@@ -119,6 +123,7 @@
* @param Handler $validation
* @param Action $action
* @param Checkout $checkoutConfiguration
+ * @param \Magento\Sales\Model\OrderFactory $orderFactory
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @codeCoverageIgnore
*/
@@ -134,7 +139,8 @@
KcoPaymentStatus $paymentStatus,
Handler $validation,
Action $action,
- Checkout $checkoutConfiguration
+ Checkout $checkoutConfiguration,
+ \Magento\Sales\Model\OrderFactory $orderFactory,
) {
$this->kcoSession = $kcoSession;
$this->initializer = $initializer;
@@ -148,6 +154,7 @@
$this->validation = $validation;
$this->action = $action;
$this->checkoutConfiguration = $checkoutConfiguration;
+ $this->orderFactory = $orderFactory;
}
/**
@@ -181,7 +188,17 @@
$this->mageQuote = $this->workflowProvider->getMagentoQuote();
try {
- $magentoOrder = $this->mageOrderRepository->get($this->mageQuote->getReservedOrderId());
+ // Start: Convert Fix for checkoing already created orders by Increment ID.
+ $reservedOrderIncrementId = $this->mageQuote->getReservedOrderId();
+ $orderModel = $this->orderFactory->create()->loadByIncrementId($reservedOrderIncrementId);
+
+ if (!$orderModel->getId()) {
+ throw new NoSuchEntityException(__('Order ID is empty.'));
+ }
+
+ $magentoOrder = $this->mageOrderRepository->get((int)$orderModel->getId());
+ $this->mageOrder = $magentoOrder->setCanSendNewEmailFlag(false);
+ // Finish: Convert Fix for checkoing already created orders by Increment ID.
// It means the order already exists and we return it so that we do not create another one
return $magentoOrder;