Loading 0

My Blog

Scroll Down

Adding volumetric weight to woocommerce with a simple function.

Adding volumetric weight to woocommerce with a simple function.

Here you have finally created your own eshop and everything is working correctly (payments, shipping, weight calculation, order processing, etc.) and where you are preparing the next steps in the development of your business, an order with the wrong shipping appears (at least that's what you think in principle).

You check the order and realize that the shipping was finally charged correctly, but your courier overcharged you.

So you look for the price list that was delivered to you during your agreement with the courier only to be confronted with the cold truth:


That damn volumetric weight of it -> (length * height * width) / 5000

And you say now, how will I solve the problem??????

And you start looking for a bunch of plugins in wordpress and woocommerce which, all they do is make your life even more difficult.

Η ΛΥΣΗ ?????

A simple function, so easy and so very useful.

In case you have never passed a function in wordpress before, install the following plugin: https://el.wordpress.org/plugins/my-custom-functions/

Immediately after, go here: (your site address)/wp-admin/options-general.php?page=my-custom-functions

Paste the following code into the window 😉

//dimensional weight function by NicolasLagios.com
add_filter( 'woocommerce_product_get_weight', 'custom_get_weight_from_dimensions', 10, 2 );
function custom_get_weight_from_dimensions( $weight, $product ) {
$dim_weight = $product->get_length() * $product->get_width() * $product->get_height() / 5000;
return $dim_weight > $weight ? $dim_weight : $weight;

Click where it says Save Changes

Immediately after the page reloads, press where it says OFF (in red) and turn it ON (in green) and press Save Changes for better or for worse.


Finally, because we need to empty the Woocommerce cache, go here: (your site address)/wp-admin/admin.php?page=wc-status&tab=tools

And click clear transients (woocommerce transients)


Now you will see that when the volumetric weight exceeds the normal weight, then the volumetric weight is selected instead of the normal one and end of the wrong charges.


Good luck and please if you want to republish my article, I'm happy to, but also leave a reference to me.


Thanks, Nikos 😉

This post is also available in: Ελληνικά

Leave a Reply

Your email address will not be published. Required fields are marked *


Here you can see all the services I provide

Registration and management of domain names (website address such as www.nicolaslagios.com)

Also management of dns records (e.g. connecting the domain to a specific server, fixing email spam problems, etc.)

Also ssl renewals etc

Installation and management of web & mail server in ubuntu vps with virtualmin, plesk, cpanel

Also studying and fixing server problems.

Necessary condition, the target server meets the conditions

At the moment for new wordpress websites you can choose from ready-made themes and we change the content (no custom changes). You can buy with a fixed price by clicking here!

My team and I undertake any data bridging implementation for Wordpress, Prestashop, Opencart, Joomla platforms.

We can connect data from any source, as long as the structure is stable and there is proper documentation and briefing.

We undertake the creation, regulation and enrichment of pages for social networks: Facebook, Linkedin, Instagram (profile), Twitter (profile), Tiktok (profile).

We also undertake the first boost of your pages for quick results in followers.

We undertake the repair and maintenance of your existing wordpress website.

For more information about the services, you can read the following and return here to schedule a meeting with me: https://maxservices.gr/en/internet-services/website-services-blank/additional-website-services/