The WooCommerce USPS Shipping Method and the UPS Shipping Method extensions makes it easy for you to charge your customers for shipping cost at checkout. The only problem, is that they are both a calculator for all products in the cart, and does not exclude products based on shipping classes. So an order can only use one shipping method.
Recently on a site I was working on for a designer the site needed to offer free shipping within the US on a specific product category and charge the customer for shipping on all other products. The scenario required the ability to have two different shipping methods (Free and Paid) dependent upon the products in the order and shipping location. To accomplish this task we needed the one order divided into two carts.
So all the products that could qualify for free shipping are assigned a shipping class.
In this example I am calling the shipping class freepromo.
Then free shipping is enabled in the WooCommerce Shipping Settings. Then the USPS and UPS shipping methods are enabled and configured. At this point every time a customer is in the US they will get free shipping. If they are not in the US they will be given a choice of UPS and USPS shipping rates.
So we still need to set up:
- Free shipping only for products being shipped in the US with the freepromo shipping class
- USPS and UPS shipping options for customers not in the US buying the freepromo products
- USPS and UPS shipping options for customers purchasing all other products.
- Free shipping and USPS and UPS shipping options for customers that purchase freepromo and non-freepromo products in one order.
There is a free plugin called Multiple Packages for WooCommerce. The plugin does work but it does not allow for additional shipping options for products with the freepromo shipping class that don’t qualify for free shipping. It also makes free shipping available to the product that does not have the freepromo shipping class.
To allow all four use cases we need to add a little code to functions.php or a site specific plugin.
In the code shown above you will need to change the shipping class name and the available shipping methods in the ship_via array.
Here are some examples of what the cart looks like in different scenarios:

This image shows the cart for a product that does not belong to the freepromo class.

Based on the freepromo restrictions the customer does not qualify for free shipping of the freepromo product because they are not in the US.

US customer is ordering a product that has the freepromo shipping class and one product that pays shipping.
Note: The code shown above is code from the Multiple Packages for WooCommerce plugin that I modified to meet the requirements of the project.
Would you be able to programming something very similar to this for me? How can I contact you?
Hi David,
Please visit https://pintopsolutions.com/contact/ and tell me more about your project.