Recently I came about a problem for a WooCommerce site I was working on. My client wanted to charge a cheaper rate the more items were purchased. In this post, I will guide you through the steps you need to take to achieve this.

Digging through the internet I found an article that shed some light onto me on the matter. For a section of the article, the writer talked about Flat Rate Settings, and how one can use them to multiply a flat rate by the number of items purchased using the [qty] shortcode.

WooCommerce Flat Rate Settings

This was, however, unsatisfactory, as it was only a linear scaling of the shipping cost. I noticed the use of the ‘*’ operator and wondered if I could do a bit more complex math than as advertised. *SPOILER ALERT*: yes, I could.

So I went on to

(1) Plot Estimated Shipping-Costs on a graph.

image.png Item Count (X) vs. Shipping Cost (Y) is easy to use and pretty self-explanatory. This amazing site gave me a myriad of function options trying to fit the plots. Linear was no use to me, but Polynomial and Nonlinear functions were close to what I needed.

(2) Select a Function function options

Ultimately I decided to go with a Power Function because even though the polynomials were more accurate, I wanted to make this as simple as possible for the Flat Cost input field.

Power Function as graphed by

Now all I needed to do was

(3) Input Function into WooCommerce Flat Rate Cost Settings

and see if this would actually work.

Power Function for Shipping Costs

The function ended up performing as expected, and my client saved a few-dozen dollars.

Because we are using a function, this operation scales infinitely. This can be a big positive or negative depending on your project.

Checkout Snapshot

Carrying out these steps immediately impacts me as a great way to utilize the most out of WooCommerce’s free capabilities. Knowing how to apply functions can be an extremely effective tool. My client is left very satisfied with the ability to further define the plot-points and chose the function himself.