Jump to content

HTTP 500 error by adding cart to back-end

Recommended Posts

Posted (edited)

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';


        $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']);
                header("Location: index.php");
 catch (PrestaShopException $e)
 	echo $e;


Edited by beaudenheijer (see edit history)

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More