If you are using Opencart version 3.0.3.5 and 3.0.3.6 you must have come across an issue related to the Extension Modification system. The twig files won’t apply and you may see abnormal errors after extension installation.
This issue happens when you click the refresh icon on the Extension Modification page. And you will see no changes done for the extension. In fact some abnormal things might happen.
So in order to fix the issue related to that you must change one single file and it would fix your issue.
Twig Modification Fix For Opencart 3.0.3.5 and 3.0.3.6
So what is the fix?
- You must log in to your server via cPanel or Filezilla.
- And then go to the System folder.
- Open modification.xml file.
- Replace all the code with the content below.
- So the full path will be System – Modification.xml
<?xml version="1.0" encoding="utf-8"?>
<modification>
<name>Modification Default</name>
<code>default</code>
<version>1.1</version>
<author>OpenCart Ltd</author>
<link>http://www.opencart.com</link>
<file path="system/{engine,library}/{action,loader,config,language}*.php|system/library/template/template.php">
<operation>
<search regex="true">
<![CDATA[~(require|include)(_once)?\(([^)]+)~]]>
</search>
<add position="replace">
<![CDATA[$1$2(modification($3)]]>
</add>
</operation>
</file>
<file path="system/library/template/twig.php">
<operation>
<search>
<![CDATA[if (is_file($file)) {]]>
</search>
<add position="replace">
<![CDATA[if (defined('DIR_CATALOG') && is_file(DIR_MODIFICATION . 'admin/view/template/' . $filename . '.twig')) {
$code = file_get_contents(DIR_MODIFICATION . 'admin/view/template/' . $filename . '.twig');
} elseif (is_file(DIR_MODIFICATION . 'catalog/view/theme/' . $filename . '.twig')) {
$code = file_get_contents(DIR_MODIFICATION . 'catalog/view/theme/' . $filename . '.twig');
} elseif (is_file($file)) {]]>
</add>
</operation>
</file>
</modification>
Once the above code is added. Save the file. And go to Admin – Extension – Modification and click refresh icon.
Issue Resolved.