Jump to content

Code 200 but "Fatal error" message in white screen


Recommended Posts



After installed the mailchimpintegration module, we got some white page with a "fatal error" message, when customer is conected with stuff in his cart.


Code 200 , juste "fatal error" displayed, nothing else. If DEV mode , a huge array with customer data is displayed.


event with xDebug activated, no backtrace, no line, nothing...


After a long  investigation time, i found that this is throw in the core class Product ObjectModel :

public static function getPriceStatic(.....){
if (!$context) {
   $context = Context::getContext();
$cur_cart = $context->cart;
//..line 2806
if (!is_object($cur_cart) || (Validate::isUnsignedInt($id_cart) && $id_cart && $cur_cart->id != $id_cart)) {
            * When a user (e.g., guest, customer, Google...) is on PrestaShop, he has already its cart as the global (see /init.php)
            * When a non-user calls directly this method (e.g., payment module...) is on PrestaShop, he does not have already it BUT knows the cart ID
            * When called from the back office, cart ID can be inexistant
            if (!$id_cart && !isset($context->employee)) {
//-> here is the throwed error:
                die(Tools::displayError()); // ligne 2814
            $cur_cart = new Cart($id_cart);
            // Store cart in context to avoid multiple instantiations in BO
            if (!Validate::isLoadedObject($context->cart)) {
                $context->cart = $cur_cart;

For now, here is the state of my investigation :


1 - this method is call when you load product with the $full parameters. ex: new Product(456, true);


2 - if there is no cart data in context, and the method is call without a cart_id in parameters, and there is no employee logged : die(Tools::displayError());


3 - i found that the cart data are set in the context instance in : FrontController:initContent() method.


4 - i found that mailchimp register the hook "hookActionObjectCartUpdateAfter" . this registre method load a product with the $full parameter (see 1).


5 My conclusion: there is somewere something that throw the ActionObjectCartUpdateAfte (so a saved cart object), before theFrontController:initContent() method.


So now, here is my questions:


a: why not a more explicite error message?

b: how to go further?



Edited by Cawet (see edit history)
Link to comment
Share on other sites

I have the same error as you.

Once i start the checkout process with a product in my cart, then i get the "Fatal error" notification and nothing else.

If i go back to the homepage, i from now also get the error. The error displays on all pages and it's then impossible to remove the item from the cart.


If anyone else met the issue, i would be glad to know if they fixed it.


FYI, i'm testing on localhost and the Prod version of my website is also connected, but on another mailchimp list, but same account. I don't think it's related, but who knows...

Also, since our Prestashop has been modified, i wonder how the module knows when to trigger the functions such as these in the checkout process or newsletter subscription etc...


Thanks in advance.

Edited by bbgun91 (see edit history)
Link to comment
Share on other sites

If i anderstand bbgun91, you've got mailchimpimplementation installed to ? But on you'r prod version there is also this module but everything is working without fatal error message  ?


Also, since our Prestashop has been modified, i wonder how the module knows when to trigger the functions such as these in the checkout process or newsletter subscription etc...



What do you mean "since ou Prestashop has been modified ? "


See the step 4 i describe in my previous post, the trigger is there, if i andesrtoud properly your question.

Link to comment
Share on other sites


 Same problem here. In the mailchimpintergration.php file on line 470 the syncCarts() method reads like this:

private function syncCarts()
        // get abandoned cart :
        $store_currency_format = CurrencyCore::getCurrenciesByIdShop($this->context->shop->id)[0]['iso_code'];
        $sql = "SELECT * FROM (
		c.firstname, c.lastname, c.email email, c.optin,  a.id_cart total, ca.name carrier, c.id_customer id_customer, a.id_cart, a.date_upd,a.date_add, IFNULL(o.id_order, 'Non ordered') id_order
		FROM "._DB_PREFIX_."cart a  
				LEFT JOIN "._DB_PREFIX_."customer c ON (c.id_customer = a.id_customer)
				LEFT JOIN "._DB_PREFIX_."currency cu ON (cu.id_currency = a.id_currency)
				LEFT JOIN "._DB_PREFIX_."carrier ca ON (ca.id_carrier = a.id_carrier)
				LEFT JOIN "._DB_PREFIX_."orders o ON (o.id_cart = a.id_cart)
				ORDER BY a.date_upd DESC LIMIT 1
		) AS toto WHERE id_order='Non ordered' AND id_customer IS NOT NULL";

        $sql_result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
        $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
        $data = array();
        $store_id = $this->context->shop->id;

        foreach ($sql_result as $cart_hash) {
            $url = 'ecommerce/stores/'.$store_id.'/carts';
            $cart_data = $this->formatCartArray($cart_hash);

            $result = $this->sendApiRequest($url, 'POST', $cart_data);

            if ($result['status'] == 400) {
                $url .= '/'.$cart_hash['id_cart'];
                $result = $this->sendApiRequest($url, 'PATCH', $cart_data);

Looking at the SQL there seems to be something odd with the id_cart field.

Specifically the fact it is queried as "a.id_cart total" (as if this is supposed to be a money total?) and then later in the SQL you see the field being hit again "a.id_cart".

Is this possible misuse of a field, its data, and position in the sent array causing an issue when it hits mail chimp with the data; possibly blowing up the session with the user? Just a thought. I really would like to see them get this corrected, because other than new customers NOT being able to buy after signing up, the data shown in mail chimp is awesome. We acquire quite a few customers on a daily basis with about 85% of those who create an account actually buy something. The day and a half that this module was active, zero new customers purchased. Presumably because all of them got a "fatal error" white page right after registration.

Link to comment
Share on other sites

has say in my first post, the error is throw from the Product Class.

It occure because a full lazy loading is call for a product (in the formatCartArray), when at this time the cart context isn't setted yet (see the code piece i posted).


And the cart context isn't setted yet, because the syncCarts method is call by the hookActionObjectCartUpdateAfter, and this last, in your and my shop, is triggered before the

FrontController:initContent() method, witch set the cart Context.


1 all day to anderstood all of that, i hop this is clearest here than in my first post x)


I temporaly solved this like this:

 private function syncCarts()
        $context = Context::getContext();
        if($context->cart ==null)

But what i don't anderstand, is what is this crapy result cause by this "die(Tools::displayError());" line, in the Product Class ?


"Fatal error" string, no line, no file, nothing, and a ugly dumped data array when the dev mod is enabled. A classical Try catch with a classical throwed error class can show all the backtrace in one time, and it could save 1day investigation...


The other thing i whant to know, is why the hookActionObjectCartUpdateAfter is call before the context is inited, in yours and mine shop, when it's not for the other shop magority. (meabe a module?)

Edited by Cawet (see edit history)
Link to comment
Share on other sites

  • 9 months later...



I have a similar problem. I installed MailChimp Integration add-on and since then, I've got an error when I choose "Pay by bank wire" and click "Proceed to check out" button. Same "fatal error" in a white page.

I use Prestashop and MailChimp Integration v1.1.2 - by NuRelm Inc.

Any idea?

Link to comment
Share on other sites

  • 1 year later...

Same problem here. I am building a front contoller, pulling products from a category, eventually it triggers the getPriceStatic function, which the OP identified as the trigger of the error.

Oddly, when I get the context in the constructor of the front controller, the cart property is empty. When I print the cart property from any other page besides my front controller, the cart is not empty. It's like it forgets to initialize the cart and doesnt push it into the context object in the front controller.

class mymodulemyfrontcontrollerModuleFrontController extends ModuleFrontController
    public function __construct()
        $this->context = Context::getContext(); //doing this won't fix anything, the cart object continues to be empty
        if(!$this->context->cart) //this will be TRUE, since the cart object is empty
            $this->context->cart = new Cart(); //so I am just making a new one. Hopefully my customers don't lose any items from their cart due to this.


Link to comment
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...