Jump to content
beaudenheijer

HTTP 500 error by adding cart to back-end

Recommended Posts

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.

image.thumb.png.46dc12d8d15442248c47868137d34c67.png

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

 

Edited by beaudenheijer (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

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