I found this extension that adds "order history" in the customers page.
Thing is it's quite old, so I downloaded the file and start looking around on how to adapt it.
I found two threads (this one and this one) where someone mentions that OpenCart 3.X works with both .tpl and .twig files so, I have two options:
1. I adapt the .tpl file from the extension and convert it somehow to .twig (I guess I need to change the code variables, etc.)
2. Try something like this extension that maybe helps with the .twig/.tpl thing?
Any ideas?
Thanks a lot!
Hey! Thanks for the help!
I've tried that and I also modified the code so it points out in the right direction (it said .tpl and I changed it to .twig since I changed the file to that format).
Didn't work though
Should I maybe install it manually?
Thanks!
What error you are seeing? Just saying didn't work is not enough to understand .
Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature
It depends on what it is, but these things can range from 30 seconds to days.
It is a little like saying I have some French and I need English
A line in french to English (except it has to be perfect English to work) takes 30 seconds
A novel will take days
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
With Google search, it only takes between 5-10 secs regardless.by mona wrote: ↑Sat Oct 17, 2020 5:08 pmConverting an extension from php OC2 to twig OC3 is out of your skill set at this stage.
It depends on what it is, but these things can range from 30 seconds to days.
It is a little like saying I have some French and I need English
A line in french to English (except it has to be perfect English to work) takes 30 seconds
A novel will take days
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I can’t type that fast .. I might break a nail ...
standards must be maintained even in these difficult times !
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
No worries. That's why it takes the right people to do it without breaking a nail.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Seems like a mess and is not that important anyway, not at the moment at least.by mona wrote: ↑Sat Oct 17, 2020 5:08 pmConverting an extension from php OC2 to twig OC3 is out of your skill set at this stage.
It depends on what it is, but these things can range from 30 seconds to days.
It is a little like saying I have some French and I need English
A line in french to English (except it has to be perfect English to work) takes 30 seconds
A novel will take days
Way to go would be to change the variables so they match with .twig "format"?
There's nothing on the customer's tab, no order history at all. No errors at all and the log on Extensions > Modifications doesn't say anything related to this extension.
What I did was modify the "vqmod/xml/order_history.xml" so it matches with the correct file paths.
I highlighted what I changed:
Code: Select all
<modification>
<id>Add orders tab to customer page</id>
<version>1.0.2</version>
<vqmver>2.x</vqmver>
<author>Dennis Mortensgaard (DoWEB I/S)</author>
<file name="admin/view/template/customer/[b]customer_form.twig (it said .tpl)[/b]">
<operation>
<search position="after"><![CDATA[<li><a href="#tab-ip" data-toggle="tab"><?php echo $tab_ip; ?></a></li>]]></search>
<add>
<![CDATA[<li><a href="#tab-orders" data-toggle="tab"><?php echo $tab_orders; ?></a></li>]]>
</add>
</operation>
<operation>
<search position="before"><![CDATA[$('#ip').load('index.php?route=customer/customer/ip&token=<?php echo $token; ?>&customer_id=<?php echo $customer_id; ?>');]]></search>
<add>
<![CDATA[$('#orders').load('index.php?route=customer/customer/orders&token=<?php echo $token; ?>&customer_id=<?php echo $customer_id; ?>&sort=o.date_added');]]>
</add>
</operation>
<operation>
<search position="before"><![CDATA[<div class="tab-pane" id="tab-ip">]]></search>
<add>
<![CDATA[
<div class="tab-pane" id="tab-orders">
<div id="orders"></div>
</div>
]]>
</add>
</operation>
</file>
<file name="[b]admin/language/*/customer/customer.php (I replaced the * with "es-es")[/b]">
<operation>
<search position="before"><![CDATA[$_['heading_title']]]></search>
<add>
<![CDATA[$_['tab_orders'] = 'Order history';]]>
</add>
</operation>
</file>
<file name="admin/controller/customer/customer.php">
<operation>
<search position="after"><![CDATA[$data['tab_ip'] = $this->language->get('tab_ip');]]></search>
<add>
<![CDATA[$data['tab_orders'] = $this->language->get('tab_orders');]]>
</add>
</operation>
<operation>
<search position="before"><![CDATA[public function ip() {]]></search>
<add>
<![CDATA[
public function orders() {
$this->load->language('sale/order');
$this->load->model('sale/order');
$data['text_no_results'] = $this->language->get('text_no_results');
$data['text_see_order'] = $this->language->get('text_see_order');
$data['text_loading'] = $this->language->get('text_loading');
$data['column_order_id'] = $this->language->get('column_order_id');
$data['column_status'] = $this->language->get('column_status');
$data['column_date_added'] = $this->language->get('column_date_added');
$data['column_date_modified'] = $this->language->get('column_date_modified');
$data['column_total'] = $this->language->get('column_total');
$data['column_action'] = $this->language->get('column_action');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
$data['orders'] = array();
$results = $this->model_sale_order->getOrders(array('filter_customerid' => $this->request->get['customer_id'], 'sort' => $this->request->get['sort'], 'order' => 'DESC'));
foreach ($results as $result) {
$data['orders'][] = array(
'id' => $result['order_id'],
'status' => $result['order_status'],
'date_added' => date('d/m/y', strtotime($result['date_added'])),
'date_modified' => date('d/m/y', strtotime($result['date_modified'])),
'action_view' => $this->url->link('sale/order/info', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'], 'SSL'),
'action_edit' => $this->url->link('sale/order/edit', 'token=' . $this->session->data['token'] . '&order_id=' . $result['order_id'], 'SSL'),
'total' => $this->currency->format($result['total'], $result['currency_code'], $result['currency_value'])
);
}
$this->response->setOutput($this->load->view('[b]customer/customer_orders.twig (it said .tpl)[/b]', $data));
}
]]>
</add>
</operation>
</file>
<file name="admin/model/sale/order.php">
<operation>
<search position="before"><![CDATA[if (!empty($data['filter_customer'])) {]]></search>
<add>
<![CDATA[
if (!empty($data['filter_customerid'])) {
$sql .= " AND o.customer_id = " . $this->db->escape($data['filter_customerid']);
}
]]>
</add>
</operation>
<operation>
<search position="before"><![CDATA[public function getTotalOrdersByOrderStatusId($order_status_id) {]]></search>
<add>
<![CDATA[
public function getTotalOrdersByCustomerId($customer_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE customer_id = '" . (int)$customer_id . "' AND order_status_id > '0'");
return $query->row['total'];
}
]]>
</add>
</operation>
</file>
</modification>
Code: Select all
<table class="table table-bordered">
<thead>
<tr>
<td class="text-left"><?php echo $column_order_id; ?></td>
<td class="text-left"><?php echo $column_status; ?></td>
<td class="text-left"><?php echo $column_date_added; ?></td>
<td class="text-left"><?php echo $column_date_modified; ?></td>
<td class="text-left"><?php echo $column_total; ?></td>
<td class="text-left"><?php echo $column_action; ?></td>
</tr>
</thead>
<tbody>
<?php if ($orders) { ?>
<?php foreach ($orders as $order) { ?>
<tr>
<td class="text-left">#<?php echo $order['id']; ?></td>
<td class="text-left"><?php echo $order['status']; ?></td>
<td class="text-left"><?php echo $order['date_added']; ?></td>
<td class="text-left"><?php echo $order['date_modified']; ?></td>
<td class="text-left"><?php echo $order['total']; ?></td>
<td class="text-right">
<a href="<?php echo $order['action_view']; ?>" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="View"><i class="fa fa-eye"></i></a>
<a href="<?php echo $order['action_edit']; ?>" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
</td>
</tr>
<?php } ?>
<?php } else { ?>
<tr>
<td class="text-center" colspan="6"><?php echo $text_no_results; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
Code: Select all
<table class="table table-bordered">
<thead>
<tr>
<td class="text-left">{{ column_order_id }}</td>
<td class="text-left">{{ column_status }}</td>
<td class="text-left">{{ column_date_added }}</td>
<td class="text-left">{{ column_date_modified }}</td>
<td class="text-left">{{ column_total }}</td>
<td class="text-left">{{ column_action }}</td>
</tr>
</thead>
<tbody>
{% if orders %}
{% for order in orders %}
<tr>
<td class="text-left">#{{ order.id }}</td>
<td class="text-left">{{ order.status }}</td>
<td class="text-left">{{ order.date_added }}</td>
<td class="text-left">{{ order.date_modified }}</td>
<td class="text-left">{{ order.total }}</td>
<td class="text-right">
<a href="{{ order.action_view }}" data-toggle="tooltip" title="" class="btn btn-info" data-original-title="View"><i class="fa fa-eye"></i></a>
<a href="{{ order.action_edit }}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
</td>
</tr>
{% endfor %}{% endif %}
{% else %}
<tr>
<td class="text-center" colspan="6">{{ text_no_results }}</td>
</tr>
</tbody>
</table>
https://www.opencart.com/index.php?rout ... n_id=39911
And the last code is not converted one...
Example:
<?php echo $column_order_id; ?> = {{ column_order_id }}
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
My bad, the code was not converted. Now it is, I edited the post.xxvirusxx wrote: ↑Sun Oct 18, 2020 2:26 pmIf you use VQMOD then you need to add Vqmod modification fix...
https://www.opencart.com/index.php?rout ... n_id=39911
And the last code is not converted one...
Example:
<?php echo $column_order_id; ?> = {{ column_order_id }}
After installing that Vqmod modification fix, should I just proceed to replace the code with the converted one? Thanks!
Give it a shot first if it didn’t work system will let you know which line has a error, generally in development when writing the code its easy to test them by running instead of reading them over and over again
Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature
Users browsing this forum: No registered users and 219 guests