i am using opencart 3.0.2.0 and journal 3.
I am creating a module that gets a value from a table and i want to pass the template variable to the twig.
The twig that i want to pass the variable is order_edit twig.
i make the query in the database from the controller/order.php and i want to display it to order_edit twig.
no matter what i am trying to do, the value just doesn't show, not even the default value that i store in it.
Code: Select all
<modification>
<name>Add iView code to mail order</name>
<version>1.0</version>
<author>Dimitrios Petasis</author>
<code>add_iview_code_to_mail_order</code>
<!-- Modify the order.php controller -->
<file path="catalog/controller/mail/order.php">
<operation>
<!-- Search for the line to place code after -->
<search limit="1"><![CDATA[$order_info = $this->model_checkout_order->getOrder($order_id);]]></search>
<!-- Add your code after the searched line -->
<add position="after"><![CDATA[
// Load the model
$this->load->model('account/order');
$this->load->model('extension/module/order_custom_field');
// Retrieve the order details
$order_info = $this->model_checkout_order->getOrder($order_id);
// Retrieve the custom value from the database
$query = $this->db->query("SELECT value FROM " . DB_PREFIX . "order_custom_field_order_value WHERE order_id = '" . (int)$this->session->data['order_id'] . "'");
if ($query->num_rows) {
$data['iView_code'] = $query->row['value']; // Assuming the column name is 'value'
} else {
$data['iView_code'] = '1111111111'; // Set a default value if not found
}
]]></add>
</operation>
</file>
<!-- Modify the order_edit.twig template -->
<file path="catalog/view/theme/default/template/mail/order_edit.twig">
<operation>
<!-- Search for a specific line in the template -->
<search><![CDATA[<p><span style="font-family: 'Play', sans-serif; font-size: 14pt;">Συνημμένα θα βρείτε το αποδεικτικό της παραγγελίας σας με αριθμό {{ order_id }}.</span></p>]]></search>
<!-- Replace the found line with your custom content -->
<add position="replace"><![CDATA[
<p><span style="font-family: 'Play', sans-serif; font-size: 14pt;">Στον παρακάτω σύνδεσμο μπορείτε να βρείτε το αποδεικτικό της παραγγελίας σας με αριθμό {{ order_id }}.</span></p>
<p><span style="font-family: 'Play', sans-serif; font-size: 14pt;">Δείτε online την Απόδειξη Λιανικής Πώλησης εδώ : www.iview.gr/{{ iView_code }} ή από τη σελίδα http://www.iview.gr με τη χρήση του κωδικού: {{ iView_code }}</span></p>
]]></add>
</operation>
</file>
</modification>