Jump to content
BrockleyJohn

Customer Orders Tab in Admin Orders (hook)

Recommended Posts

This uses the hooks system and tabbed display of admin / orders implemented by the Paypal App.

It adds a tab to admin / orders which lists all orders from the customer of the current order.
The current order is highlighted. Clicking on one of the other orders will load it instead.
Works for all orders, not just those paid by Paypal.

COMPATIBILITY
Compatible with the tabbed admin orders page of the Paypal App in any version of osCommerce (2.2RC2, 2.3.x).
FILENAMES DEPRECATED - if your admin / orders page is not called orders.php you'll have to change the hard-coded name in the module.
Not compatible with BS EDGE Hooks of 2016-10-03 (which don't cover admin).

Uses tradition language defines, not Paypal App-style.

INSTALLATION
Just copy the 3 files to your store.
No code changes and no admin install - it just works.

 

DOWNLOAD

from the addons area http://addons.oscommerce.com/info/9511

GITHUB
also available in a branch on its own in a fork of gburton/Responsive-osCommerce at:
https://github.com/BrockleyJohn/Responsive-osCommerce/tree/addon_customer_orders_tab
 

Edited by BrockleyJohn

For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

screenshot:

post-220375-0-05238300-1475915455_thumb.jpg


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Hi, dont work in bootstrao gold?

 

If you have implemented the Paypal App, then yes it does.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Hi, yes i have paypal app, but the addon dont change nothing in orders.php.


No external links here, thank you

Share this post


Link to post
Share on other sites

Hi, yes i have paypal app, but the addon dont change nothing in orders.php.

 

But it can... follow the instructions of section 3 here (also 2 if you haven't already):

https://library.oscommerce.com/Package&en&paypal&oscom23&installation

Edited by BrockleyJohn

For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

The paypal app ist installed and working, but im not have any change for installin. i follow the instruccions step 2/3, this is the result.

AH01071: Got error 'PHP message: PHP Warning: require(/includes/classes/hooks.php): failed to open stream: No existe el fichero o el directorio in admin/includes/application_top.php on line 248\nPHP message: PHP Warning: require(/var/www/vhosts/nukua.es/prueba.nukua.es/includes/classes/hooks.php): failed to open stream: No existe el fichero o el directorio in admin/includes/application_top.php on line 248\nPHP message: PHP Fatal error: require(): Failed opening required 'includes/classes/hooks.php' (include_path='.:/usr/share/php:/usr/share/pear') in /admin/includes/application_top.php on line 248\n'

line 248 admin/includes/aplication_top.php

                       require(DIR_FS_CATALOG . 'includes/classes/hooks.php');
                       $OSCOM_Hooks = new hooks('admin');

No external links here, thank you

Share this post


Link to post
Share on other sites

 

The paypal app ist installed and working, but im not have any change for installin. i follow the instruccions step 2/3, this is the result.

AH01071: Got error 'PHP message: PHP Warning: require(/includes/classes/hooks.php): failed to open stream: No existe el fichero o el directorio in admin/includes/application_top.php on line 248\nPHP message: PHP Warning: require(/var/www/vhosts/nukua.es/prueba.nukua.es/includes/classes/hooks.php): failed to open stream: No existe el fichero o el directorio in admin/includes/application_top.php on line 248\nPHP message: PHP Fatal error: require(): Failed opening required 'includes/classes/hooks.php' (include_path='.:/usr/share/php:/usr/share/pear') in /admin/includes/application_top.php on line 248\n'

line 248 admin/includes/aplication_top.php

                       require(DIR_FS_CATALOG . 'includes/classes/hooks.php');
                       $OSCOM_Hooks = new hooks('admin');

The clue's in the error message - you didn't upload the file from the (Paypal App) addon. It was in

docs/legacy/v234/includes/classes/hooks.php
Edited by BrockleyJohn

For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Great! first tab addon for orders page. As a side note, it just sjows with customers with more than one order (at first I tought it wasn't working because of that).

Share this post


Link to post
Share on other sites

Great! first tab addon for orders page. As a side note, it just sjows with customers with more than one order (at first I tought it wasn't working because of that).

 

Yes, that was by design - I thought it would be annoying to have to click on the tab to find it's the only order. I could perhaps have mentioned it though!


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@@BrockleyJohn I'm playing with the tabs by putting the stock ones into hooks. Do you know a way to order the tabs?

 

Brute force, I'm afraid: http://stackoverflow.com/questions/3050830/reorder-list-elements-jquery

 

I don't know of a clever css/bs way...


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

Now compatible with BS Edge with no core code changes: upload and go.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@@BrockleyJohn

 

I have installed this and I dont seem to have an 'All Orders' tab showing even though there are 3 test orders placed.

 

Am I missing something?

 

Thanks

 

Mark


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

@@PupStar what osc version are you on?

 

NB you only get the tab if there's more than one order for the customer of the order you're looking at

Edited by BrockleyJohn

For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@@PupStar what osc version are you on?

 

NB you only get the tab if there's more than one order for the customer of the order you're looking at

 

@@BrockleyJohn

 

I am using the latest version of Edge which I downloaded 02/10

 

I have placed 4 test orders for the same customer and still no 'All Orders' tab


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

@@BrockleyJohn

 

I am using the latest version of Edge which I downloaded 02/10

 

I have placed 4 test orders for the same customer and still no 'All Orders' tab

 

aha - you need to get the changes that include the paypal app - that went into core on 14/10 (or any of the catalog hooks stuff)

... if you don't want  the whole thing, just grab

- admin / orders.php and its language file,

- admin / includes / application_top.php

- includes / classes / hooks.php

can't think of any others off the top of my head, but it'll soon tell you if I missed any!


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

aha - you need to get the changes that include the paypal app - that went into core on 14/10 (or any of the catalog hooks stuff)

... if you don't want  the whole thing, just grab

- admin / orders.php and its language file,

- admin / includes / application_top.php

- includes / classes / hooks.php

can't think of any others off the top of my head, but it'll soon tell you if I missed any!

@@BrockleyJohn,

 

ok grabbed them files and nothing has changed and no errors urgh


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

@@PupStar well, it should. I just took Edge from 27 September on a clean install and added the above files from the latest Edge. That gave me a tabbed order display on admin / orders

 

At that stage only 3 tabs of course

 

Then I uploaded the files from the addon and the fourth tab appeared.

 

If you've a tabbed display, no extra tabs and no errors, you probably didn't upload the addon file to includes / hooks / admin / orders

 

If you've no tabbed display, you need the new version of admin / orders.php


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@@PupStar well, it should. I just took Edge from 27 September on a clean install and added the above files from the latest Edge. That gave me a tabbed order display on admin / orders

 

At that stage only 3 tabs of course

 

Then I uploaded the files from the addon and the fourth tab appeared.

 

If you've a tabbed display, no extra tabs and no errors, you probably didn't upload the addon file to includes / hooks / admin / orders

 

If you've no tabbed display, you need the new version of admin / orders.php

@@BrockleyJohn

 

ok did a fresh copy of the files, not sure what happened but its now working spot on :)

 

Thanks


Bootstrap 3 ROCKS!

(or it will if I ever get my head around it lol)

(and I think I have now (w00t) )

Share this post


Link to post
Share on other sites

@@BrockleyJohn found that there's no language support on this modue, so the orders are showing and counting repeatedly unless you filter the language used on admin in the query:

      $query = tep_db_query("SELECT o.orders_id, o.date_purchased, os.orders_status_name, o.payment_method, ots.title as order_shipping, ott.text as order_total 
	                         FROM orders o 
							 LEFT JOIN orders_total ots on (ots.orders_id = o.orders_id) 
							 LEFT JOIN orders_total ott on (ott.orders_id = o.orders_id) 
							 LEFT JOIN orders_status os on (os.orders_status_id = o.orders_status) 
							 WHERE ots.class = 'ot_shipping' 
							 AND ott.class = 'ot_total' 
                             AND os.language_id = '" . $languages_id . "'
							 AND o.customers_id in (select customers_id from orders where orders_id = '" . (int)$oID . "') 
							 ORDER by date_purchased desc");

Share this post


Link to post
Share on other sites

@@BrockleyJohn found that there's no language support on this modue, so the orders are showing and counting repeatedly unless you filter the language used on admin in the query:

Thanks @@piernas - the support was there, what was lacking was (multi) language testing! Fix published.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@@BrockleyJohn

 

Two questions ...

 

1) The download has three files. Are these to be copied into the /catalog/includes folder, or the /catalog/admin/includes folder? This addon is for the Admin side of the site, but the instructions aren't clear.

 

2) (slightly off topic) Can someone 'modularize' the three existing tabs (Summary, Products, & Status History) into standalone bits that hook into Admin like this one does? This way, a store owner can add to, replace, or delete any of the tabs without 'core' changes.

 

Thanks!

 

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@@BrockleyJohn

 

Two questions ...

 

1) The download has three files. Are these to be copied into the /catalog/includes folder, or the /catalog/admin/includes folder? This addon is for the Admin side of the site, but the instructions aren't clear.

 

2) (slightly off topic) Can someone 'modularize' the three existing tabs (Summary, Products, & Status History) into standalone bits that hook into Admin like this one does? This way, a store owner can add to, replace, or delete any of the tabs without 'core' changes.

 

Thanks!

 

Malcolm

 

1. Put them in catalog/includes. I have updated the structure in the download zip for the avoidance of doubt.

2. Even in 2.4 the original tabs are not hooked. However if you don't want to see one or more of them, I expect you could hide them with styles and avoid core changes.


For a new install or if your store isn't mobile-friendly, get the community-supported responsive osCommerce (Phoenix).

here: on the official osc download page

Working on generalising bespoke solutions for Quickbooks integration, Easify integration and pay4later (DEKO) integration at 2.3.x

Share this post


Link to post
Share on other sites

@@BrockleyJohn

 

Don't know what I'm doing wrong here .... copied over the 3 files (and added the language check as noted earlier), and I'm now getting this error ...

Parse error: syntax error, unexpected end of file in C:\wamp\www\catalog-bc\includes\modules\hooks\admin\orders_customer_tab.php on line 103

Here's the file

<?php
/*
  $Id$

  add customer orders tab to admin / orders.php

  author: John Ferguson @[member=BrockleyJohn] john@sewebsites.net

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2016 osCommerce
  Released under the GNU General Public License
*/

  class hook_admin_orders_customer_tab {
    
    function load_language() {
      global $language;
      include_once(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/hooks/admin/' . basename(__FILE__));
    }

    function execute() {
      global $oID;
      $this->load_language();

      $output = '';
      $status = array();

      $query = tep_db_query("SELECT o.orders_id,
                                    o.date_purchased,
                                   os.orders_status_name,
                                    o.payment_method,
                                  ots.title as order_shipping,
                                  ott.text as order_total
                             FROM ".TABLE_ORDERS." o
                               left join ".TABLE_ORDERS_TOTAL." ots on (ots.orders_id = o.orders_id)
                               left join ".TABLE_ORDERS_TOTAL." ott on (ott.orders_id = o.orders_id)
                               left join ".TABLE_ORDERS_STATUS." os on (os.orders_status_id = o.orders_status)
                             where ots.class = 'ot_shipping'
                               and ott.class = 'ot_total'
                               AND os.language_id = '" . $languages_id . "'
                               and o.customers_id in (select customers_id from ".TABLE_ORDERS." where orders_id = '" .

(int)$oID . "')
                             order by date_purchased desc");

      if ( tep_db_num_rows($query) > 1 ) {

// if there are more orders - make a list of them (this one highlighted, others clickable to load admin orders page)
        $order_list = '<table border="0" width="100%" cellspacing="0" cellpadding="5">
                         <tr class="dataTableHeadingRow">
                           <td class="dataTableHeadingContent">'.TABLE_HEADING_DATE_PURCHASED.'</td>
                           <td class="dataTableHeadingContent" align="right">'.TABLE_HEADING_ORDER_TOTAL.'</td>
                           <td class="dataTableHeadingContent">'.TABLE_HEADING_STATUS.'</td>
                           <td class="dataTableHeadingContent">'.TABLE_HEADING_PAYMENT_METHOD.'</td>
                           <td class="dataTableHeadingContent">'.TABLE_HEADING_SHIPPING_METHOD.'</td>
                         </tr>
        ';


        while ($order = tep_db_fetch_array($query)) {

          if ($order['orders_id'] == $oID) {
            $order_list .= '              <tr id="defaultSelected" class="dataTableRowSelected"

onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="">' . "\n";

          } else {

            $order_list .= '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)"

onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link('orders.php',

tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $order['orders_id'] . '&action=edit') . '\'">' . "\n";
          }

          $order_list .= '
              <td class="dataTableContent">'. tep_datetime_short($order['date_purchased']) .'</td>
              <td class="dataTableContent" align="right">'. strip_tags($order['order_total']) .'</td>
              <td class="dataTableContent">'. $order['orders_status_name'] . '</td>
              <td class="dataTableContent">'. $order['payment_method'] .'</td>
              <td class="dataTableContent">'. $order['order_shipping'] .'</td>
            </tr>
          ';

        }

        $order_list .= '</table>'."\n";

        $tab_title = addslashes(TAB_CUSTOMER_ORDERS);
        $tab_link = substr(tep_href_link('orders.php', tep_get_all_get_params()), strlen($base_url)) .

'#section_customer_orders';

        $output = <<<EOD

          <script>
            $(function() {
              $('#orderTabs ul').append('<li><a href="{$tab_link}">{$tab_title}</a></li>');
            });
          </script>

          <div id="section_customer_orders" style="padding: 10px;">
            $order_list
          </div>
        EOD;

      }

      return $output;
    }
  }

Malcolm

Edited by ArtcoInc

Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×