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

Display Total weight in Admin/orders

Views: 8,045

Results 21 to 26 of 26
29 Aug 2013, 9:20 PM
#21
mydanilo avatar

mydanilo

Totally Zenned

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

Display Total weight in Admin/orders

Looked at the USPS mod a bit closer and stripped out what is not needed to just give me the total weight on the order page. Works like a charm. Hit me up if you want to do the same thing.
Modified my orders.php with just this code from the USPS mod orders.php

         <?php // ====> BOF: USPS.com AutoFill <==== ?>
         <?php require(DIR_WS_MODULES . 'usps_autofill_button.php'); ?>
         <tr><td align="right" colspan="2"><?php echo "Total Weight is $lbsval lbs. $ozval oz."; ?></td></tr>
         <?php // ====> EOF: USPS.com AutoFill <==== ?>

Uploaded the two needed files in corresponding directory
functions_ordertotalweight.php
usps_autofill_button.php

Executed the following SQL:
SET @gid=0;
SELECT @gid:=configuration_group_id
FROM configuration_group
WHERE configuration_group_title LIKE '%USPS Auto-Fill Config%'
LIMIT 1;
DELETE FROM configuration_group WHERE configuration_group_title LIKE '%USPS Auto-Fill Config%';
DELETE FROM configuration_group WHERE configuration_group_title LIKE '%USPS AutoFill%';
DELETE FROM configuration_group WHERE configuration_group_title LIKE '%USPS AutoFill Config%';
DELETE FROM admin_pages WHERE page_key='uspsautofill';
DELETE FROM configuration WHERE configuration_key LIKE 'USPS_RETURN%' LIMIT 8;
DELETE FROM configuration WHERE configuration_key LIKE 'USPS_DELIVERY%' LIMIT 9;

#ok until here 8 statements processed

Insert New USPS AutoFill Configuration Group

INSERT INTO configuration_group VALUES ('', 'USPS AutoFill', 'USPS AutoFill Config', '1', '1');
SET @gid=last_insert_id();
UPDATE configuration_group SET sort_order = @gid WHERE configuration_group_id = @gid;
#ok until here 3 statements processed

INSERT INTO configuration VALUES (NULL, 'Delivery: Default Weight (Pounds)', 'USPS_DELIVERY_DEFAULT_WEIGHTS_POUNDS', '', 'Set this to the default weight in pounds. Useful if you sell only one type of item. Leave blank if using the order total weight', @gid, '55', now(), now(), NULL, NULL),
(NULL, 'Delivery: Default Weight (Ounces)', 'USPS_DELIVERY_DEFAULT_WEIGHTS_OUNCES', '', 'Set this to the default weight in ounces. Useful if you sell only one type of item. Leave blank if using the order total weight', @gid, '60', now(), now(), NULL, NULL),
(NULL, 'Delivery: Default Shipping from Same ZipCode (Radio Button)', 'USPS_DELIVERY_SAME_ZIPCODE', 'same', 'Set this to same if you want to have your Return Address Zipcode as the default Ship-From zipcode. If set to Other, then enter in your default Ship-From zipcode in the next setting', @gid, '65', now(), now(), NULL, "zen_cfg_select_option(array('same', 'other'),"),
(NULL, 'Delivery: Default Shipping from Other ZipCode (If Radio Button set to Other)', 'USPS_DELIVERY_OTHER_ZIPCODE', '', 'Set the default ZipCode you would like as your Ship-From zipcode. Only if the above setting is set to Other', @gid, '70', now(), now(), NULL, NULL),
(NULL, 'Delivery: Default Insurance Value', 'USPS_DELIVERY_INSURANCE_VALUE', '', 'Set to total or subtotal if you want to use that order value for the insurance value, or set to a price (i.e. 5.25) if you want to use a preset price. Or leave blank to not use it', @gid, '75', now(), now(), NULL, NULL);
ALTER TABLE orders DROP total_weight;
ALTER TABLE orders ADD total_weight FLOAT NOT NULL DEFAULT '-1';

#Below seems not needed for my weight total mod only

Register the pages for Admin Access Control

#DELETE FROM admin_pages WHERE page_key='uspsautofill';
#INSERT INTO admin_pages (page_key,language_key,main_page,page_params,menu_key,display_on_menu,sort_order) VALUES ('uspsautofill','BOX_CONFIGURATION_USPS_AUTOFILL','FILENAME_CONFIGURATION','1','configuration','Y','1');
#UPDATE admin_pages SET sort_order = (SELECT configuration_group_id FROM configuration_group WHERE configuration_group_title = 'USPS AutoFill') WHERE page_key = 'uspsautofill';
#UPDATE admin_pages SET page_params = CONCAT('gID=',(SELECT configuration_group_id FROM configuration_group WHERE configuration_group_title = 'USPS AutoFill')) WHERE page_key = 'uspsautofill';

That was it. Maybe not an elegant solution but it works for me.

18 May 2015, 12:21 AM
#22
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
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

Ajeh,

Was "shipping_weight_total" added to any of the 1.5x releases?

18 May 2015, 12:38 AM
#23
ajeh avatar

ajeh

Oba-san

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

Re: Display Total weight in Admin/orders

Afraid not ...

In v1.6 there will be a new field for the Order's total weight in the table:
orders

called:
order_weight

18 May 2015, 12:42 AM
#24
split63 avatar

split63

Totally Zenned

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

Re: Display Total weight in Admin/orders

I know you will hate this question, but do you have a wild guess on the release of 1.6?

18 May 2015, 12:57 AM
#25
ajeh avatar

ajeh

Oba-san

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

Re: Display Total weight in Admin/orders

Hopefully sometime this year ... :wow: ... if everybody prays really hard ...

25 Jan 2018, 4:01 PM
#26
sarahl avatar

sarahl

Zen Follower

Join Date:
May 2004
Location:
UK
Posts:
471
Plugin Contributions:
0

Re: Display Total weight in Admin/orders

I am aware that this is a very old post however I needed to get the value of the WEIGHT of the order and as it looks like 1.5.x versions still are not saving the shipping weight, so I used Ajeh helpful post. But people were getting errors when using this - the error on the text below is the column name inserted into the table doesn't match what you insert via the orders class.. once they match up this works for me

So
edit table

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

classes/shipping.php

      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]

then classes/orders.php

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

and that works for me

Thanks
Sarah

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 ...