Jump to content

Error 500 PHP Fatal error: Uncaught Error: Call to a member function setTemplate() on null in /config/smartyfront.config.inc.php:97


make69

Recommended Posts

I got this error on frontend. Whenever a customer clicked "Complete payment" (the last step) There was an error 500.

When one reloaded the Error 500 page it showed the order confirmation.

 

What solved the issue was to open the file /config/smartyfront.config.inc.php
and editing the function starting on line 95

function smartyRender($params, &$smarty)
{
    $ui = $params['ui'];

    if (array_key_exists('file', $params)) {
        $ui->setTemplate($params['file']);
    }

    return $ui->render($params);
}

into 

function smartyRender($params, &$smarty)
{
    $ui = $params['ui'];

    if ($ui !== null) {
        if (array_key_exists('file', $params)) {
            $ui->setTemplate($params['file']);
        }

        return $ui->render($params);
    } else {
        // Handle the case where $params['ui'] is null
        // You can throw an exception, log an error, or take appropriate action.
    }
}

The if checks whether the value $ui is null and if it is not it does what prestashop wants it to do (setTemplate etc) but if it in fact IS null it just does nothing.

Please feel free to add a function in the area where the comments are ( // ... )

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 6 months later...

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...