I have added an extra field to the oc_order table in an Opencart database.
However, when I try and check if it exists or displays the data in that filed, I see nothing.
I have updated the catalogue/view/theme/account/order_info.twig file with the following to test both displaying the new field and using an if statement...
{{ newfield }} {% if newfield == true %}
WORKS
{% else %}
NOT WORKING
{% endif %}
I have a '1' inset in the database but I always get the 'NOT WORKING' displayed.
Any help much appreciated.
to retrieve data from db and show it on your template you should First, in corresponding controller file retrieve data from DB
$query = "SELECT newfield FROM " . DB_PREFIX . "table_name ";
Than you should declare it in the same controller file
if ($query->rows) {
$data['newfield'] = $query->row['newfield'];
} else {
$data['newfield'] = '';
}
Now you can retrieve it in your template
{% if newfield %}
WORKS {{ newfield }}
{% else %}
NOT WORKING
{% endif %}