Zen Cart Logo
Forums / Basic Configuration / Display Total weight in Admin/orders

Display Total weight in Admin/orders

Views: 8,045

Results 1 to 20 of 26
26 Mar 2008, 7:31 PM
#1
rhodesengr avatar

rhodesengr

New Zenner

Join Date:
Aug 2007
Posts:
59
Plugin Contributions:
0

Display Total weight in Admin/orders

Is there a way to display the total weight of an order on the admin/order page? I do get weight total for some shipping methods and not for others. If the order uses USPS, then I do get a weight total next to the shipping cost. The Fedex module does not display the weight, just the cost. So it seems the weight total is fed to the order page from the shipping module and is module dependent. The shopping cart tracks the total weight plus tare weight. It would be nice to get this to display in the orders. Thanks.

I am using ZC 1.3.7

Mark
https://www.essential-stuff-store.com

3 Mar 2009, 8:48 PM
#2
cpowell1 avatar

cpowell1

New Zenner

Join Date:
Mar 2008
Posts:
21
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

Did anyone ever figure out how to do this? If calculating the order weight is too complicated to do from the admin interface, I'd be happy to add a field to the orders table and save the weight when the order is saved. I'm just not sure where the best place to do this is.

(And the site is live, so I don't want to have to do too much random experimenting if I can help it. :-)

4 Mar 2009, 4:58 AM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Total weight in Admin/orders

I would add a new field to the orders table as:
shipping_weight_total decimal(14,5)

hint: it will match future updates ... :cool:

4 Mar 2009, 6:22 PM
#4
cpowell1 avatar

cpowell1

New Zenner

Join Date:
Mar 2008
Posts:
21
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

Thanks for the hint!

You don't happen to know off the top of your head where the order is saved, do you, and if the weight is available at that time? I followed the process up to where it starts using the weight in the shopping cart, then the "I've had enough of this!" kicked in and I gave up. :yuck:

20 May 2009, 2:53 AM
#5
coryinit avatar

coryinit

New Zenner

Join Date:
May 2009
Posts:
3
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

I've added the field to the orders table, as you suggested, but I'm unsure where in all the files to find/modify the SQL insert statement to put this in the orders table after a successful checkout. Can anyone please point me in the right direction.

20 May 2009, 4:05 AM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Total weight in Admin/orders

Look in the orders.php class and see where the tables are updated with each order for:
orders
orders_products
orders_products_attributes

20 May 2009, 6:24 PM
#7
coryinit avatar

coryinit

New Zenner

Join Date:
May 2009
Posts:
3
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

Thank you Ajeh,

To all searching for a UPS ODBC integration to UPS World Ship 2009 v11, here is what I did:

Note*
World Ship must already be installed on a windows PC that has tcp access to your database server port 3306. UPS has WorldShip available for free from your online account tools. From a security standpoint, I would not probably try this across the Internet unless your host offers SSL connections and can firewall access to the database server port 3306 to allow only connections from your single world ship IP address. If your DB server is on your Lan, then you can manage the security directly.


  1. Add a read only user to your zen-cart database. This will allow you to create a System or User DSN on the PC with World Ship installed.

  2. On the PC with World Ship installed download the MySQL ODBC v 3.51 connector (the newest one causes and exception in worldship) from http://dev.mysql.com/downloads/connector/odbc/3.51.html Install this.

  3. After the MySQL ODBC Driver install go to Start -> Control Panels -> Administrative Tools -> Data Sources (ODBC). Click on the System DSN tab and click Add... Select the "MySQL 3.51 ODBC 3.51 Driver" and Click Finish.

In the Connector/ODBC window enter the following:
Data Source Name: ZENCART
Description: [Whatever you want]
Server: [IP Address of your DB Server]
User: [The read only account you just made in step 1]
Password: [just what it is]

Test the connection.

  1. Follow the instructions in the document titled "Import Shipment Data Using the ODBC Feature and Keyed Import" found here: http://www.ups.com/content/us/en/resources/techsupport/worldship/documents/index.html

This is fairly straight forward except on step 4, you will select "By Known ODBC Source" instead of "By File" like the instructions. You only need to enter the name of your "Data Source Name" from step 3 in the "Data Source Name (DSN):" box if you entered the username and password in step 3.

Complete the rest of the instructions as described in the UPS Document.

  1. If you want to add the total shipping weight (without the tare corrections, i.e. small to medium package 10:1) to the import you will need to run this command from either the mysql command line or the sql patches:

**** NOTE ****
BE SURE TO CHANGE "prefix" IN THE FOLLOWING COMMAND TO WHATEVER YOUR TABLE PREFIX IS


alter table prefix_orders add shipping_weight_total decimal(14,5);

Then edit your /includes/classes/order.php on line 613 where it reads:

'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR']
);

change it to this:

'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR'],
'shipping_weight_total' => $_SESSION['cart']->weight
);

Once this is done you will need to edit the map in world ship by clicking on Import/Export Data -> Create / Edit Map... and selecting the map you made above. Just connect the shipping_weight_total to the appropriate WorldShip weight field.

Now in WorldShip just go to Import/Export Data -> Keyed Import -> More... and select the new map you created. It will prompt you for an order id then fill in all the fields for you. You can also set this up to automatically print the labels on new orders (Hands-Off Shipping), but I would get very comfortable with this hack before doing this.

Good Luck, I hope this helps someone else. If there is a way to override the order.php file I would recommend doing so, but I am pretty new to this so I'm not sure where I should put it.

Thanks,
-Cory

7 Apr 2010, 2:30 AM
#8
gicandles avatar

gicandles

New Zenner

Join Date:
Apr 2010
Posts:
1
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

I have added the shipping_weight_total field to the orders table. I however, can not get the weight to display on the orders page in admin.

I have tried several different ways of polling the db with no success.

Does anyone have any suggestions as to the code that should be added to the orders.php to have the information displayed?

Thanks!

(using zen 1.3.8) no mods to the orders.php file.

7 Apr 2010, 4:46 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Total weight in Admin/orders

How are you trying to get the weight from the orders table? :unsure:

7 Apr 2010, 4:50 PM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Total weight in Admin/orders

NOTE: the shipping weight is already, by default, stored in the orders_total on the class when it is ot_shipping and the orders_id matches the orders_id in the orders table ...

22 Oct 2011, 4:47 PM
#11
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

coryinit:

  1. If you want to add the total shipping weight (without the tare corrections, i.e. small to medium package 10:1) to the import you will need to run this command from either the mysql command line or the sql patches:

**** NOTE ****
BE SURE TO CHANGE "prefix" IN THE FOLLOWING COMMAND TO WHATEVER YOUR TABLE PREFIX IS


alter table prefix_orders add shipping_weight_total decimal(14,5);

> 
> Then edit your /includes/classes/order.php on line 613 where it reads:
> 
> ```
'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR']
);

change it to this:

'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR'],
'shipping_weight_total' => $_SESSION['cart']->weight
);

> 
> Once this is done you will need to edit the map in world ship by clicking on Import/Export Data -> Create / Edit Map... and selecting the map you made above.  Just connect the shipping_weight_total to the appropriate WorldShip weight field.
> -Cory

Is this still the best method to add total shipping weight to zen_orders?  I have v1.3.9e
30 Jan 2013, 1:21 AM
#12
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

More than a year with no response....

Anyone know how to access the total order weight?
I need to export this value to an external shipping application

30 Jan 2013, 1:35 AM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Total weight in Admin/orders

Do you need the Order Weight:

1 before the order is complete
if so, are you in the checkout when you need this?
or, are you in the shop as the order is being made but not yet in the checkout?

2 after the order is complete
if so, are you in the checkout, such as the checkout_success?
or, are you in the shop, such as the My Account
or, are you in the Admin?

30 Jan 2013, 3:56 AM
#14
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

Ajeh:

Do you need the Order Weight:

1 before the order is complete
if so, are you in the checkout when you need this?
or, are you in the shop as the order is being made but not yet in the checkout?
No, the checkout process is fine as is.
Ajeh:

2 after the order is complete
if so, are you in the checkout, such as the checkout_success?
or, are you in the shop, such as the My Account
or, are you in the Admin?
This is for order fulfillment long after orders are placed. We use the "Export Shipping & Order Information" plugin which outputs order data to a .csv file. The file is then imported into a shipping app that generates labels.
The element missing from the export is the shipping weight for each order.
If I knew where in the database the order total weight was kept (if it is kept), then I can alter the plugin to also output the total order weight for each order.

31 Jan 2013, 12:48 AM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Display Total weight in Admin/orders

You need to add a new field, such as:
shipping_weight_total

to the table:
orders

use the sql:

alter table orders add shipping_weight_total decimal(14,5);

which you can run in the Tools ... Install SQL Patches ...

or, use phpMyAdmin, as be sure to address the table prefix if you use them ...

Then, you need to save the weight to a session variable, in the shipping class:

      switch (true) {
        // large box add padding
        case(SHIPPING_MAX_WEIGHT <= $shipping_weight):
          $shipping_weight = $shipping_weight + ($shipping_weight*($zc_large_percent/100)) + $zc_large_weight;
          break;
        default:
        // add tare weight < large
          $shipping_weight = $shipping_weight + ($shipping_weight*($zc_tare_percent/100)) + $zc_tare_weight;
          break;
      }

[B]// bof: save weight for later use
  $_SESSION['total_order_weight'] = $shipping_weight;
// eof: save weight for later use[/B]

Next, you need to customize the order class to add the weight to the table:
orders

with:

                            'order_total' => $this->info['total'],
                            'order_tax' => $this->info['tax'],
                            'currency' => $this->info['currency'],
                            'currency_value' => $this->info['currency_value'],
                         [B] 'shipping_weight' => $_SESSION['total_order_weight'],[/B]
                            'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR']
                            );

and that should work with most shipping modules ...

NOTE: be careful of shipping modules where there are other weight calculations in it that may be different than the weight calculation of shipping class and will need to be addressed differently ...

29 Aug 2013, 12:22 PM
#16
mydanilo avatar

mydanilo

Totally Zenned

Join Date:
Dec 2004
Posts:
1,024
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

I am loosing it. I have one site where I always see the total weight of an order (in Adming - Customers - Orders) just below the purchased products it shows:
Total Weight is 12 lbs. 0 oz.
Sub-Total: $135.00
Free Shipping Options (Free Shipping): $0.00
Sales Tax: $0.00
Total: $135.00

On all my other up to date 1.5.1 sites it does not show a Total Weight line with Free Shipping Options used. If UPS and USPS shipping options were used to complete the order, shipping weight shows on the order detail in admin. I don't believe I've done any of the above mentioned modifications on this particular site. If, then it was many years ago on an very old Zen version. I've been upgrading this site from 1.3.0 on to today so it is possible that an add on executed some sql in the past that added the needed stuff. How do I go about to have this Total Weight show on my order detail page that I need to process the orders. I need the weight calculation on Free Shipping as well. Not sure why this is not standard anyway. If I need to ship goods, it has a weight even if customer does not pay for it.

29 Aug 2013, 1:49 PM
#17
mydanilo avatar

mydanilo

Totally Zenned

Join Date:
Dec 2004
Posts:
1,024
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

Would the USPS.com Click-n-Ship AutoFill Button module return total weight on the order detail in admin for ALL order no matter if free shipping? Maybe just installing this module could do the trick or one could implement some of the code just for weight display purpose. Just a thought...

I would rather just fix it without needing to install/merge this whole add on.

29 Aug 2013, 2:16 PM
#18
mydanilo avatar

mydanilo

Totally Zenned

Join Date:
Dec 2004
Posts:
1,024
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

Ajeh:

You need to add a new field, such as:
shipping_weight_total

to the table:
orders

use the sql:

alter table orders add shipping_weight_total decimal(14,5);

> 
> which you can run in the Tools ... Install SQL Patches ...
> 
> or, use phpMyAdmin, as be sure to address the table prefix if you use them ...
> 
> Then, you need to save the weight to a session variable, in the shipping class:
> ```
      switch (true) {
        // large box add padding
        case(SHIPPING_MAX_WEIGHT <= $shipping_weight):
          $shipping_weight = $shipping_weight + ($shipping_weight*($zc_large_percent/100)) + $zc_large_weight;
          break;
        default:
        // add tare weight < large
          $shipping_weight = $shipping_weight + ($shipping_weight*($zc_tare_percent/100)) + $zc_tare_weight;
          break;
      }

[B]// bof: save weight for later use
  $_SESSION['total_order_weight'] = $shipping_weight;
// eof: save weight for later use[/B]

Next, you need to customize the order class to add the weight to the table:
orders

with:

                        'order_total' => $this->info['total'],
                        'order_tax' => $this->info['tax'],
                        'currency' => $this->info['currency'],
                        'currency_value' => $this->info['currency_value'],
                     [B] 'shipping_weight' => $_SESSION['total_order_weight'],[/B]
                        'ip_address' => $_SESSION['customers_ip_address'] . ' - ' . $_SERVER['REMOTE_ADDR']
                        );
> 
> and that should work with most shipping modules ...
> 
> NOTE: be careful of shipping modules where there are other weight calculations in it that may be different than the weight calculation of shipping class and will need to be addressed differently ...

Tried this too and I get a "WARNING: An Error occurred, please refresh the page and try again. " at the last step of checkout where the order confirmation should display. If I remove the line "'shipping_weight' => $_SESSION['total_order_weight']," again, then I can checkout. I must say I use COWOA, maybe that makes it fail?
29 Aug 2013, 2:45 PM
#19
mydanilo avatar

mydanilo

Totally Zenned

Join Date:
Dec 2004
Posts:
1,024
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

I notice that my orders table has the field total_weight stored in the 1.3.9a installation where the weight displays correctly. I think this is from the USPS auto fill mod.

How do other store users get to display total weight of an order with free shipping? We all need to ship the products even if we grant free shipping to our customers. I don't understand that this is not a present and ready function of core install. Did I miss something?

29 Aug 2013, 8:02 PM
#20
mydanilo avatar

mydanilo

Totally Zenned

Join Date:
Dec 2004
Posts:
1,024
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

Well, as nobody joins in I keep posting my progress. I have now installed the newest USPS Auto fill 1.6 and this does give me the order total weight even on older existing orders. Kind of overkill as I don't want the USPS autofill anymore on my newest installs. If somebody has another working solutions it would be much appreciated.