Skip to content

Commit

Permalink
delete cart on fail
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijusCoding committed Oct 23, 2024
1 parent f035583 commit 4c716a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions controllers/front/failIFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ public function initContent()
{
parent::initContent();

$cart = new \Cart(Tools::getValue('cartId'));

/**
* Note: deleting cart prevents
* from further failing when creating order with same cart
*/
$cart->delete();

/** @var LoggerInterface $logger */
$logger = $this->module->getService(LoggerInterface::class);

Expand Down
5 changes: 3 additions & 2 deletions controllers/front/return.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,13 @@ private function getOrderId($cartId)
*/
private function getRedirectionToControllerUrl($controllerName)
{
$cartId = $this->context->cart->id ? $this->context->cart->id : Tools::getValue('cartId');
return $this->context->link->getModuleLink(
$this->module->name,
$controllerName,
[
'cartId' => $this->context->cart->id,
'orderId' => Order::getOrderByCartId($this->context->cart->id),
'cartId' => $cartId,
'orderId' => Order::getOrderByCartId($cartId),
'secureKey' => $this->context->cart->secure_key,
'moduleId' => $this->module->id,
]
Expand Down

0 comments on commit 4c716a8

Please sign in to comment.