woocommerce tutorials

WooCommerce ZIP code fees: add charges per location

We got an interesting question in our support desk recently that is a great way to illustrate the power of shipping classes in WooCommerce. A merchant needed a way to add surcharges based on customer location — specifically, the ability to have WooCommerce zip code-based fees:

Is there a way to change the price of a product based on a customer’s zip code?

The ability to add postcode-based product fees can help stores add surcharges when delivering to or performing services for specific municipalities where the business must pay extra fees.

It can also be a great way to bake in surcharges for areas that are hard to get to, such as creating a delivery surcharge for an address in the middle of a city, which will add significant transit time for couriers.

There are no plugins that cover this specific use case — but there’s a way to create these zip code product fees based on shipping zones instead, no plugins required. Let’s dive in!

We’ll create a shipping class that manages how shipping is charged based on the shipping zone, then we’ll create a high priority zone that covers all the zip codes that should have location-based pricing, fees, or surcharges.

Add a postcode fees shipping class

The first thing we need to do is create our shipping class. You can create this under WooCommerce > Settings > Shipping > Classes. When you add a new shipping class, you’ll give it a name and a description. In our case, we’ll use this class to show items that should have surcharges in some zones, so I’ve called it Surcharge.

Once you’ve created this zone, you can then assign it to any products that should have this WooCommerce zip code surcharge under the product’s “shipping” settings. Bet you’ve never really paid attention to this shipping class selector before. 😉

Create WooCommerce shipping zones

Now we’re ready to set up the shipping zones and costs for these surcharges. I’ve created three shipping zones in my test store:

  • My rest of the world zone covers non-USA purchases — anyone who isn’t matched to one of my first 2 zones will be charged my international flat rate shipping.
  • My United States zone will cover purchases across the USA that I’ll ship, and I offer a domestic flat rate method + a free method for high value orders (a great way to increase average order value).
  • My Local zone will have the postcodes that need to add surcharges for the products in my special shipping class. Since I want this zone to be matched any time it applies, I have it first in my list.

Make sure your zones are in order. Your “local” zone should come first in the list (you can drag and drop using the dot menu on the left to reorder zones). WooCommerce always tries to match zones in the order you’ve provided.

Now you can configure the shipping methods in your zones. I’m focusing on the Local zone, because that’s where my WooCommerce zip code-based fees are going to be applied. Enter your zip codes here that should have a surcharge for your selected products. You can have a list (one per line), match wildcards, or add numerical ranges of postcodes (as my example does).

Add WooCommerce zip code fees as shipping class costs

Now make sure your shipping costs are done correctly. Shipping classes add to the base shipping cost, which may be new for some merchants. Most folks use the base cost as the shipping fee and don’t leverage classes (which is fine for your general / international shipping zones).

To charge our location-based product fees, we need to be conscious of all shipping charges. The main cost will always be applied, then shipping class fees are added to this cost. You can choose whether a cart with multiple shipping classes has all the shipping class fees added, or if only the highest shipping class fee is added.

In my case, I have opted to keep the main cost $0 for clarity and just enter the costs I want on shipping classes instead. For items that have no shipping class, I’ll charge $3.99 flat rate, but for items that have my surcharge shipping class, I’ll also add a 10% cart subtotal fee (minimum $4). You can create some really advanced quantity or percentage based fees using flat rates.

Now my WooCommerce zip code-based product fees will be added when users match my Local zone postcodes! For a customer in 01863, they’ll match my regular “USA” zone, and get the base $3.99 shipping. For a customer who matches the zip codes in the Local zone, they’ll now get a location-based price: $3.99 + the minimum $4 fee = $7.99.

If a customer matched the local zone, but had no Surcharge items in the cart, they would just see the $3.99 fee instead.

WooCommerce zip code-based product fees

There you have it! You can easily add location based surcharges, product fees, or shipping costs using the baked in WooCommerce shipping zones and shipping classes. Be sure that you:

  1. Create shipping classes and assign them to your relevant products
  2. Create a shipping zone for the postcodes that have surcharges or extra fees (and make sure it’s first in your list!)
  3. Add the fees to the shipping methods in your surcharge zone.

You’ll now have dynamic, location-based shipping costs for your products.

Beka Rice Avatar

About the author…

Join the Flock

Product updates, sales & coupons, Woo tutorials. Zero spam.


Comments

Leave a Reply

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