Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics

WooCommerce add-on: Shop order total weight empty


I added your Total Order Weight column only to find that the weight of product variations is omitted.

I took a peek in the file ac-addon-woocommerce/classes/Column/ShopOrder/TotalWeight.php and modified it to make it work.


$weight = (int) $item->get_quantity() * (float) get_post_meta( $item->get_product_id(), '_weight', true );


$weight = (int) $item->get_quantity() * (float) $item->get_product()->get_weight();

If you find a more efficient fix, please let me know when the updated plugin will be available and/or what code you’re gonna use so I can update my cowboy style hotfix :D


2 years, 4 months ago

Thanks for your input.
I’ve created a ticket for this.

Since you’ve opened the file to make your change, you probably also found the comment above that line.
We did intentionally use the get_post_meta method instead of the get_product()->get_weight() because of performance reasons. I’ll have a look if we alter the get_post_meta call to use the product or variation ID or that we still use your suggestion and ignore the performance penalty.

In the meantime, you could have a look at this hook in order to use your solution instead of hacking it in the plugin.


At least you won’t lose your changes next time you update the plugin when we did not yet implemented the chosen solution.

2 years, 4 months ago

We decided to use your method after all.
It’s better to show the correct value instead of making the column better performant.

2 years, 1 month ago

You must be logged in to reply to this topic.