The Blog

Easily Change WooCommerce Shipping Prices

I work with WooCommerce everyday. It’s my life, my job and my passion. At Woo, we recently introduced a new workflow where we split up into teams that focus on a specific set of WooCommerce extensions. For me, my focus on is shipping.

So I do a lot of shipping stuff. It sort of consumed me after a while. I can quickly think up a zip code to match a certain US state, or one that works for the UK. I know which address fields each country expects and the main shipping providers all over the world.

But regardless of all this, I still get a lot of requests from people that want to take it a step further. They want to customise the shipping that little bit extra, but I can only help to a certain extent, as writing custom code takes time – time we just don’t have. Instead, I’d prefer to spend my only personal time writing the code, allowing me to share it with our customers and you!

Today’s custom code is a simple introduction to how you can manipulate WooCommerce shipping rates.

The main filter we’ll be hooking into is woocommerce_package_rates. I’ve used it in a couple tutorials before, so if you’ve paying attention, you already know what to expect.

So today someone wanted to know how they could reduce the shipping by a certain amount. Fair enough. I get that. I understand you, dear customer. Let me try help.

Check out the code above. It’s hooking into the package rates and then going through each rate, adjusting the cost and then returning the adjusted rates.

Above it’s finding the price it was before a 10% tax was applied, but what if you wanted to just add $5 onto each rate. Also easy:

Don’t be afraid to play with it and do some fun calculations!

Introducing Metorik

For

A single dashboard unifying your store's orders, customers, and products, helping you understand your data and make more informed decisions.