Post by xwalker » Fri Oct 28, 2022 10:05 pm

how can i show the total weight on an order in admin (or on the shipping list)
thanks in advance

Newbie

Posts

Joined
Wed Feb 24, 2021 6:04 pm

Post by straightlight » Fri Oct 28, 2022 11:40 pm

OC version.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by paulfeakins » Mon Oct 31, 2022 7:10 pm

xwalker wrote:
Fri Oct 28, 2022 10:05 pm
how can i show the total weight on an order in admin (or on the shipping list)
thanks in advance
If you can't find an extension, you could pay a developer such as ourselves or post a job in the Commercial Support Forum.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by pprmkr » Mon Oct 31, 2022 8:39 pm

xwalker wrote:
Fri Oct 28, 2022 10:05 pm
how can i show the total weight on an order in admin (or on the shipping list)
thanks in advance
First add some code to admin/controller/sale/order.php.
In function shipping() search:

Code: Select all

foreach ($products as $product) {
Add before:

Code: Select all

$total_weight = 0;
Then after product array:

Code: Select all

					$product_data[] = array(
							'name'     => $product_info['name'],
							'model'    => $product_info['model'],
							'option'   => $option_data,
							'quantity' => $product['quantity'],
							'location' => $product_info['location'],
							'sku'      => $product_info['sku'],
							'upc'      => $product_info['upc'],
							'ean'      => $product_info['ean'],
							'jan'      => $product_info['jan'],
							'isbn'     => $product_info['isbn'],
							'mpn'      => $product_info['mpn'],
							'weight'   => $this->weight->format(($product_info['weight'] + (float)$option_weight) * $product['quantity'], $product_info['weight_class_id'], $this->language->get('decimal_point'), $this->language->get('thousand_point'))
						);
Add after:

Code: Select all

$total_weight += ($product_info['weight'] + (float)$option_weight) * $product['quantity'];
In de order array:

Code: Select all

'product'          => $product_data,
Add after:

Code: Select all

'total_weight'	   => $this->weight->format($total_weight, $product_info['weight_class_id'], $this->language->get('decimal_point'), $this->language->get('thousand_point')),
Then edit admin/view/template/sale/order_shipping.twig.
For example at the end of the product table:

Code: Select all

          <td>{{ product.weight }}</td>
          <td>{{ product.model }}</td>
          <td class="text-right">{{ product.quantity }}</td>
        </tr>
        {% endfor %}
Add after:

Code: Select all

        <tr>
          <td colspan="2"></td>
          <td>Total weight</td>
          <td>{{ order.total_weight }}</td>
          <td colspan="2"></td>
        </tr>

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by xwalker » Thu Nov 10, 2022 12:52 am

now i get this
Notice: Undefined variable: total_weight in /var/www/vhosts/shop.hair-service.be/storage/modification/admin/controller/sale/order.php on line 1935

that is this line
$total_weight += ($product_info['weight'] + (float)$option_weight) * $product['quantity'];

Newbie

Posts

Joined
Wed Feb 24, 2021 6:04 pm

Post by pprmkr » Thu Nov 10, 2022 4:24 pm

Did you add ?
pprmkr wrote:
Mon Oct 31, 2022 8:39 pm
First add some code to admin/controller/sale/order.php.
In function shipping() search:

Code: Select all

foreach ($products as $product) {
Add before:

Code: Select all

$total_weight = 0;

User avatar
Active Member

Posts

Joined
Sat Jan 08, 2011 11:05 pm
Location - Netherlands

Post by by mona » Thu Nov 10, 2022 4:46 pm

No OC version / No theme / No extensions
Maybe its the theme / extension that is editing the change ?

@xwalker You could try putting a lot more information into your request ?

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: Baidu [Spider] and 106 guests