Latest Blog Posts

Editing the OpenCart Homepage
29.09.2025 2666 3 44 min

Editing the OpenCart homepage, customizing H1 and Title text, displaying products and modu..

How to Uninstall Powered by OpenCart
03.09.2025 4135 3 20 min

Remove Powered by OpenCart and customize footer: edit template, use theme editor or OCMOD ..

How to remove modules in OpenCart
28.08.2025 2117 3 12 min

Step-by-step instructions for deleting modules in OpenCart 3 via the admin panel, manually..

Which hosting to choose for OpenCart
25.08.2025 1436 3 19 min

Find out which hosting to choose for an OpenCart online store. Requirements, selection cri..

Fatal error: Uncaught Twig\Error\LoaderError in OpenCart

2890 0 2 min
Fatal error: Uncaught Twig\Error\LoaderError in OpenCart

Twig\Error\LoaderError error in OpenCart occurs when the system cannot load the Twig template due to a missing file, invalid paths, or version incompatibility.

Major causes of the error

  1. Incorrect paths to Twig files in the code.
  2. Missing Twig template files
  3. Incompatibility of OpenCart and Twig versions. Especially after updating OpenCart to 3.0.3.6 and higher.

Solution for different OpenCart versions

OpenCart to 3.0.3.6

  1. Update the modifier cache and the template engine cache on the main admin page by clicking on the gear button.
  2. Editing the template loader: In the file system/library/template/twig.php replace: 
$loader = new \Twig_Loader_Array(array($filename . '.twig' => $code));

to

$loader1 = new \Twig_Loader_Array(array($filename . '.twig' => $code));
$loader2 = new \Twig_Loader_Filesystem(array(DIR_TEMPLATE)); // to find further includes
$loader = new \Twig_Loader_Chain(array($loader1, $loader2));

OpenCart 3.0.3.6 and higher

$loader = new \Twig\Loader\ArrayLoader(array($filename . '.twig' => $code));

to

$loader1 = new \Twig\Loader\ArrayLoader(array($filename . '.twig' => $code));
$loader2 = new \Twig\Loader\FilesystemLoader(array(DIR_TEMPLATE)); // to find further includes
$loader = new \Twig\Loader\ChainLoader(array($loader1, $loader2));

Following these recommendations will help prevent the error from occurring again and ensure stable operation of the store.

Related Posts

Error "SyntaxError: Unexpected token < in JSON at position 0"
27.05.2020 0 2 min

Even experienced developers do not always know the reason for the error "SyntaxError: Unexpected tok..

OpenCart SSL: How to load all pages using HTTPS
17.04.2020 0 1 min

The article provides instructions on how to properly configure an SSL certificate throughout your si..

ChatGPT Consultant

Comments

Leave your comment or question

Write Comment

Popular