Support

Search results for ""

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

WooCommerce add-on: Shop order total weight empty

Hey,

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.

Before:

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

After:

$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

Thanks!

4 years, 10 months ago
Stefan van den Dungen Gronovius
Developer

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.
https://www.admincolumns.com/documentation/filter-reference/ac-column-value/
At least you won’t lose your changes next time you update the plugin when we did not yet implemented the chosen solution.

4 years, 10 months ago
Stefan van den Dungen Gronovius
Developer

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

4 years, 7 months ago

You must be logged in to reply to this topic.