In the newer version of prestashop i encountered a weird bug when you add the cart tot the back-end. the debug mode screenshot is below. and the code is below the screenshot.
require 'config/config.inc.php';
require 'init.php';
session_start();
try
{
$id = isset($_SESSION['Cart_ID']) ? (int)$_SESSION['Cart_ID'] : null;
$cart = new Cart($id, null);
$cart->save(); // problem is just in this line
$_SESSION['Cart_ID'] = $cart->id;
if($_SERVER['REQUEST_METHOD'] === "POST")
{
if(isset($_POST['add_to_cart'], $_POST['id_product']) || !empty($_POST['id_product']))
{
$cart->updateQty(1, $_POST['id_product']);
$cart->update();
header("Location: index.php");
}
}
}
catch (PrestaShopException $e)
{
echo $e;
}