I’ve seen some variation of this question multiple times from both new and experienced WooCommerce shop owners: Can I charge shipping based on the number of items in the cart instead of just a flat fee?

Definitely doable. ? The best part? You don’t even need any plugins or code snippets to do it — you can do quantity-based shipping within WooCommerce itself.

WooCommerce shipping per item

Many shop owners use the built-in WooCommerce shipping zones and rates to create their shipping fee structures. You can find these under WooCommerce > Settings > Shipping.

WooCommerce Shipping options

Notice that many of my shipping methods are flat rate methods, such as those named “Ground” or “Expedited”. By default, these charge a set rate for that zone, such as $5 per order.

However, you can do a lot more with flat rates than simple costs! This is where I encourage you to read the tooltips in WooCommerce core more frequently. ?

WooCommerce Flat Rate shipping settings

Flat Rate tooltip

You can add advanced costs such as quantity-based costs or additional fees, to your flat rate shipping. You can use this to include the item quantity in your shipping cost formula with the [qty] shortcode:

WooCommerce flat rate shipping per quantity

Now, instead of charging $3 per order, I can charge $3 per item in the cart, which means that my shipping rate can adjust based on the number of items being ordered.

WooCommerce quantity-based shipping Example 1

Example 1

WooCommerce quantity-based shipping Example 2

Example 2

This lets you create WooCommerce shipping per item rather than per order with the built-in shipping tools.

Tiered WooCommerce shipping per item

Since shipping tends to bring up all sorts of questions, let’s look at a more complex example I saw in the WooCommerce community Slack recently: I need to charge shipping in multiples of two as you can get two items per container. How would I go about doing that?

This question is interesting because it sets up a tiered shipping system rather than strictly pricing per item — this needs to change shipping for every two items, not for every item.

While more complex shipping like this can’t be done with the core tools, you could create tiered shipping with the Table Rate Shipping extension for WooCommerce. This plugin lets you create rates per item count, so you could do a table of rates like this:

Item count Shipping cost
1 to 2 $3
3 to 4 $6
5 to 6 $9
7 to 8 $12
…and so on

The benefit here is that, based on the description in my question above, I think this is supposed to be per line item quantity (given it packs similar items in a box), which Table Rate Shipping can account for with “calculated rates per line item” as the calculation type.

WooCommerce Table Rate shipping per item tiers setup

This will then change the rate using your tiers for each line item’s quantity, providing the summed total as the shipping cost to the customer:

WooCommerce Table Rate shipping per item tiers frontend

Table Rate Shipping can give you advanced WooCommerce tiered shipping based on item count, and other properties such as weight or price.

For developers: creating more WooCommerce shipping tiers

For developers, you can create even more complex shipping schemes or tiered pricing using the woocommerce_shipping_rate_cost filter (requires WooCommerce 3.2+). This lets you adjust the cost of any shipping method programmatically.

You should be comfortable with PHP code and WordPress hooks to use the examples in this section.

Let’s take the above example for tiered pricing, but do it based on the entire cart item quantity, not per line, using this filter.

First, I’ll set up the base rates for my shipping methods. I’m going to use $3 as my per box price, and then I’ll programmatically change the box count in a code snippet.

WooCommerce tiered shipping base cost

Now, I’ll filter the method cost, multiplying this base cost by my box count. I’ll get the box count by rounding the cart item quantity divided by 2 (which should give me whole numbers always for my box count). Note that you could also use a modulus operator here to check for instances where you have no remainder for cart item qty ÷ by 2.

Notice that I’m using the instance IDs for the rates I want to use this tiered pricing for. You can get this by hovering over the link to each shipping rate and you’ll see &instance_id=number in the URL (or you can inspect the HMTL for the rate to get this).

Now I’ve created a system in which I’ll get the total box count for all cart items, assuming any of my products fit 2 per box, and multiply that to the per box cost. If I have 2 items, this charges for one box:

WooCommerce tiered quantity-based shipping Example 1

Example 1

While having 5 cart items charges for 3 boxes:

WooCommerce tiered quantity-based shipping Example 2

Example 2

That’s it! There are many ways to create WooCommerce shipping per item, including using the item quantity directly, or by creating more advanced tiered rates via plugins and customization.


Note: This post may contain affiliate links, which means we get a commission from the plugin, theme, or service provider if you choose to purchase. Regardless of this, we are committed to providing high quality, unbiased resources. Have more questions? See our affiliate policy. You can use the plain links below if you prefer that we not receive a referral commission:

Your WooCommerce store can drive additional revenue by improving your email marketing. Try Jilt for free to increase sales with abandoned cart recovery emails, post-purchase follow-ups, and more!
Articles you may also like:

Posted by Beka Rice

Beka Rice manages the direction of Sell with WP content and writes or edits most of our articles to share her interests in eCommerce. Or she just writes as an excuse to spend more time jamming out to anything from The Clash to Lady Gaga. Who knows.

Leave a reply

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