Post by dippetas » Sun May 12, 2024 7:40 pm

hi,
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>
any help would be deeply appreciated.

New member

Posts

Joined
Thu Aug 23, 2018 10:20 pm

Post by IP_CAM » Sun May 12, 2024 7:55 pm

You better contact Journal Support on this, paid Journal-related matters don't belong here:
https://support.journal-theme.com/

My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by dippetas » Sun May 12, 2024 8:10 pm

thank you for replying, but this is not a journal issue, it is opencart's default mail mechanism.

New member

Posts

Joined
Thu Aug 23, 2018 10:20 pm

Post by nonnedelectari » Sun May 12, 2024 8:52 pm

Why would you add this:

Code: Select all

                $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);
after this:

Code: Select all

$order_info = $this->model_checkout_order->getOrder($order_id);
In any event, order_custom_field_order_value is not a standard table so better double check that you get something back from it by adding:

Code: Select all

$this->log->write('value from DB:'.$query->row['value']);
after

Code: Select all

$data['iView_code'] = $query->row['value']; // Assuming the column name is 'value'
so you can see in your error log if something is actually retrieved.

Active Member

Posts

Joined
Thu Mar 04, 2021 6:34 pm

Post by dippetas » Mon May 13, 2024 3:07 am

thank you all for your answers, please mark the thread as Solved.

New member

Posts

Joined
Thu Aug 23, 2018 10:20 pm

Post by straightlight » Mon May 13, 2024 3:42 am

dippetas wrote:
Mon May 13, 2024 3:07 am
thank you all for your answers, please mark the thread as Solved.
Now that the issue has been solved, please add: [SOLVED] at the beginning of the subject line on your first post.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 20 guests