Peter Wilkinson
Peter Wilkinson

Reputation: 80

Add Store Name to OpenCart 2 admin order list page

I am trying to add the store name in the order list on OpenCart. I saw this post and have tried to modify it to show store name but it doesn't work. It just displayed no results, so no orders show now.

Here is my code:

       <modification>
  <id><![CDATA[Show Store Name]]></id>
    <version>1</version>
    <vqmver>2.X</vqmver>
<author>author</author>

<file name="admin/view/template/sale/order_list.tpl">

    <operation>
        <search position="after"><![CDATA[
        <a href="<?php echo $sort_order; ?>"><?php echo $column_order_id; ?></a>
        ]]></search>
        <add><![CDATA[
        <!-- custom -->
                <td class="text-left">
                    <?php echo $text_store_name; ?></a>
                </td>

        <!-- custom -->
        ]]></add>
    </operation>
    <operation>
        <search position="after"><![CDATA[
        <td class="text-right"><?php echo $order['order_id']; ?></td>
        ]]></search>
        <add><![CDATA[
        <td class="text-left"><?php if(!empty($order['column_store'])){echo "CU".$order['column_store'];} else{echo "  ";} ?></td>
        ]]></add>
    </operation>

</file>

</modification>

Upvotes: 0

Views: 523

Answers (1)

Scott C Wilson
Scott C Wilson

Reputation: 20016

I suspect the issue you're having is that in 2.3.0.2, the function getOrders() in admin/model/sale/order.php does not query * the way the getOrder() function does. When I added the field store_name to the $sql query in getOrders(), displaying the store worked.

I didn't write an vqMod, I just modified admin/view/template/sale/order_list.tpl, admin/model/sale/order.php, admin/controller/sale/order.php as follows:

view/template/sale/order_list.tpl: (obviously you should modify the language file instead of hardcoding; this is just a POC)

103,107d102
< <!-- bof mod -->
<                   <td class="text-right">
<                      Store Name
<                   </td>
< <!-- eof mod -->
147d141
<                   <td class="text-left"><?php echo $order['store_name']; ?></td>

admin/model/sale/order.php:

173c173
<       $sql = "SELECT store_name, o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";
---
>       $sql = "SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, (SELECT os.name FROM " . DB_PREFIX . "order_status os WHERE os.order_status_id = o.order_status_id AND os.language_id = '" . (int)$this->config->get('config_language_id') . "') AS order_status, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified FROM `" . DB_PREFIX . "order` o";

admin/controller/sale/order.php:

214d213
<               'store_name'      => $result['store_name'],

Upvotes: 0

Related Questions