We got this error after PrestaShop update from 1.4.17 to 1.4.2.5: “Cart can’t be loaded or an order has already been placed using this cart” and we found the solution to this problem.
PrestaShop changed Cart’s class method from:
public function OrderExists()
{
$result = Db::getInstance()->ExecuteS('SELECT `id_cart` FROM `'
._DB_PREFIX_.'orders` WHERE `id_cart` = '.(int)($this->id));
return Db::getInstance()->NumRows();
}
To:
public function OrderExists()
{
return (bool)Db::getInstance()->getValue('SELECT `id_cart` FROM `'
._DB_PREFIX_.'orders` WHERE `id_cart` = '.(int)$this->id);
}
As you can see now it returns Boolean value not Integer.
Klarna payment module checks if the order exists with current cart with this line:
$cart->OrderExists() === 0
So now this statement returns false instead of true because variable type is not integer. It returned number of rows in earlier versions – so 0 means that there was no any order with the current cart and the statement was correct.
You can find this line in file: modules/kreditor/kreditor.php and in modules/cashondeliverywithfee/cashondeliverywithfee.php.
Check these files and change statement from:
$cart->OrderExists() === 0
to:
!$cart->OrderExists()
It will solve the problem.
It’s early morning now and I hope I described this problem clearly. Well I need more coffee. Hope this post saves somebodies time.
Good day,
I came across your solution while searching the web and it’s exactly the same problem I get when using a Netcash payment module (for South Africa), however I am using PrestaShop Version 1.4.4.0 and I don’t see the folders in the module you are referring to?
I don’t have kreditor at all and I only have cashondelivery folder but don’t find the code you are referring to.
Do you have any advice for me? I would really appreciate it.
Thank you in advance.
Kind regards,
Jhorene