Website maintenanceWooCommerce: Shipping costs - and packaging per bottle

A surcharge on the shipping costs of an online shop, depending on the number of items of a certain type of packaging - is that even possible? At the request of a customer, we found out how this can be implemented in WooCommerce. We present the result in this article.

Matthias Speth, 16 December 2021

Picture of a beautifully tidy garden

A special request reached us from our customer Saliba Alster Arcadeswho sells food in a WordPress/Woocommerce online shop.

In the shop, the shipping costs are represented by a flat rate of €9.50, which is due for every order regardless of the number of items.

Now, however, a new article should be included, the shipping of which is particularly costly due to the container in the form of certain bottles. Here, €5.00 should be added to the shipping costs for each additional bottle ordered. Do I need an extra plug-in for this? No, because the "shipping classes" of Woocommerce make this possible, because in addition to fixed amounts for each shipping class, formulas can also be entered here.

This is how it works, step by step:

1. under WooCommerce/Settings/Shipping/Shipping classes a new shipping class "Bottle shipping" has been set up.

Setting up shipping classes in WooCommerce: Step 1

The following settings have been made under Shipping zones/Germany/ Flat shipping rate:

Enter "Bottle shipping" in 'Costs for shipping class':
(([qty]-1)*5.00)
This is the magic formula and it means: item quantity ([qty]) minus one (i.e. deduction of the first item that initially triggers the flat rate) * additional surcharge from the second bottle of 5.00 EUR.
Setting up shipping classes in WooCommerce: Step 2

The new item has been assigned the shipping class "bottle shipping".

Setting up shipping classes in WooCommerce: Step 3

This is how the shipping calculator calculates as desired:
1x flat rate for everything = € 9.50 + € 5.00 per bottle from the second bottle for items with the shipping class "bottle shipping".