0

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>
mx0
  • 6,445
  • 12
  • 49
  • 54

1 Answers1

0

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'],
Scott C Wilson
  • 19,102
  • 10
  • 61
  • 83
  • How would just one line of code in the controller add the store name to the order list? thanks for the help – Peter Wilkinson Jul 25 '17 at 07:36
  • No sorry. I wanted to have a new column in the order list to be the store name and the value to be the store name for each order.. Does this make sense? Thanks – Peter Wilkinson Jul 26 '17 at 07:44
  • If you go to Sales > Orders - this is where the order list is. It is where all your orders are shown. Not a multistore. I use OpenBay and on the order it shows if the sale is on ebay or the store itself so I would like this to be shown when I look at all the orders - in the order itself it shows ebay on the store name so want this to be shown in the columns on the order list . Does this make sense? Thanks – Peter Wilkinson Jul 27 '17 at 11:32
  • OpenBay doesnt setup a new store.. It just changes the name in the Order details tab on the order. it goes: Order ID, Invoice No and then Store Name: bla bla bla.. THis is the value I need to get in the previous window (order list) Am I making sense? – Peter Wilkinson Jul 28 '17 at 15:20
  • Thanks for your help. Very kind. Excuse my ignorance but what do the numbers mean at the top? "103,107d102" - I guess it is line 103? I am ok to work out where to put it in the order_list file but not so great on sql coding so not sure where to put this as on line 173 it says: " if ($implode) { $sql .= " WHERE (" . implode(" OR ", $implode) . ")"; } else {". ----- Is this where I should put it - can you be so kind to put the lines of code before where this should go so I can search for the code in the file and work out to paste the code? Thanks – Peter Wilkinson Aug 02 '17 at 08:41
  • I Think I know what to do. I should replace the bottom line with the top one on model/sale/order.php ? I have done this and uploaded to site. I cannot see any changes. The strange thing is that I cant even see the html ( Store Name Even when I inspect the page. I have cleared the vqmod cache and still nothing. – Peter Wilkinson Aug 02 '17 at 08:51
  • For the diffs, these are the changes from the new (fixed file) to the old (original file). So the first block is a 3 line insertion starting at line 103, then a 1 line insertion starting at line 147. For the lack of visible changes: Perhaps your browser is caching the page? Can you use Developer Tools to prevent caching and test again? – Scott C Wilson Aug 02 '17 at 10:22