Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Fix error on recreateOrder if one time token is used #121

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/OrderManager/V7/OrderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ public function recreateOrder(CartInterface $cart): AbstractOrder
$sourceOrder = $this->getOrderFromCart($cart);

if ($sourceOrder) {
$tokens = $sourceOrder->getVoucherTokens();
$tokenVersionNote = '';

//create new order object
$tempOrdernumber = $this->createOrderNumber();
$order = $this->getNewOrderObject();
Expand All @@ -307,10 +310,21 @@ public function recreateOrder(CartInterface $cart): AbstractOrder
$order->setOrderdate(new Carbon());
$order->setCartId($sourceOrder->getCartId());

if ($tokens) {
dvesh3 marked this conversation as resolved.
Show resolved Hide resolved
$tokenVersionNote = ' Token previously added but removed: ';
foreach ($tokens as $token) {
$this->voucherService->removeAppliedTokenFromOrder($token, $sourceOrder);
$this->voucherService->applyToken($token->getToken(), $cart, $order);
dvesh3 marked this conversation as resolved.
Show resolved Hide resolved
$tokenVersionNote .= '"' . $token->getToken() . '"';
}
}

$order->save(['versionNote' => 'OrderManager::recreateOrder.']);

$sourceOrder->setSuccessorOrder($order);
$sourceOrder->save(['versionNote' => 'OrderManager::recreateOrder - save successor order.']);
$sourceOrder->save([
'versionNote' => 'OrderManager::recreateOrder - save successor order.'. $tokenVersionNote
]);
}

return $this->getOrCreateOrderFromCart($cart);
Expand Down