Dark Light

How to Apply Multiple Shipping Classes to Variable Products in WooCommerce

Varun Dubey 4 min read

Managing shipping costs accurately is one of the trickiest parts of running a WooCommerce store. If you sell products with multiple variations, different sizes, weights, or materials, you likely need different shipping rates for each variation. WooCommerce shipping classes let you do exactly that.

This guide walks you through setting up multiple shipping classes for variable products in WooCommerce, including per-variation shipping class assignment, flat rate configuration, troubleshooting common issues, and code snippets for advanced customization.

What Are WooCommerce Shipping Classes?

Shipping classes in WooCommerce group products with similar shipping requirements. Each class can have its own cost rules within a shipping method. For example, you might create a “Lightweight” class for small items and a “Bulky” class for oversized products, each with different flat rate costs.

When applied to variable products, shipping classes let you charge different shipping rates for each variation. A small t-shirt and a heavy hoodie can be variations of the same product but use different shipping classes and therefore different shipping costs at checkout.

Step 1: Create Your Shipping Classes

Before assigning shipping classes to product variations, you need to create them.

  1. Go to WooCommerce > Settings > Shipping > Shipping Classes.
  2. Click Add Shipping Class.
  3. Enter a name (e.g., “Lightweight”, “Standard”, “Heavyweight”, “Fragile”).
  4. Add a slug and description for each class.
  5. Click Save Shipping Classes.

Create as many classes as you need. Common examples include weight-based classes (under 1kg, 1-5kg, over 5kg) or handling-based classes (standard, fragile, oversized).

Step 2: Configure Flat Rate Costs Per Shipping Class

After creating shipping classes, you need to assign costs to each class within your shipping zones.

  1. Go to WooCommerce > Settings > Shipping > Shipping Zones.
  2. Edit the zone where you want to apply class-based rates.
  3. Click Edit on your Flat Rate shipping method (or add one if you haven’t).
  4. You’ll see cost fields for each shipping class you created:
    • “Lightweight” shipping class cost: e.g., 3.00
    • “Heavyweight” shipping class cost: e.g., 12.00
    • No shipping class cost: fallback for products without a class
  5. Set the Calculation Type:
    • Per class: Charges are calculated per shipping class (adds costs for each class in the cart)
    • Per order: Uses the most expensive shipping class cost for the entire order
  6. Click Save Changes.

The calculation type matters significantly. “Per class” is more accurate for mixed carts but can result in higher shipping costs. “Per order” simplifies pricing but may undercharge for orders with many heavy items.

Step 3: Assign Shipping Classes to Product Variations

Now assign the appropriate shipping class to each variation of your variable product.

  1. Go to Products > All Products and edit your variable product.
  2. Scroll to the Product Data section and click the Variations tab.
  3. Expand each variation by clicking the arrow.
  4. Find the Shipping Class dropdown within the variation settings.
  5. Select the appropriate shipping class for each variation.
  6. Click Save Changes, then Update the product.

Important: The parent product’s shipping class acts as the default. If a variation doesn’t have a shipping class assigned, it inherits the parent product’s class. Always set variation-level classes explicitly to avoid unexpected shipping costs.

Step 4: Test Your Shipping Setup

Always test before going live. Here’s a systematic approach:

  1. Add a lightweight variation to the cart and check the shipping cost at checkout.
  2. Add a heavyweight variation separately and verify the cost changes.
  3. Add both to the same cart and verify the calculation type (per class vs per order) behaves as expected.
  4. Test with different shipping zones if you have multiple zones configured.
  5. Check edge cases: What happens with free shipping thresholds? Do coupons interact correctly?

Use WooCommerce’s built-in Shipping Calculator on the cart page to verify rates without completing a purchase.

Advanced: Per-Variation Shipping with Code

For more control, you can programmatically set shipping class costs based on variation attributes using the woocommerce_package_rates filter:

add_filter( 'woocommerce_package_rates', 'custom_variation_shipping_cost', 10, 2 );
function custom_variation_shipping_cost( $rates, $package ) {
    $has_heavy_item = false;
    
    foreach ( $package['contents'] as $item ) {
        if ( ! empty( $item['variation_id'] ) ) {
            $variation = wc_get_product( $item['variation_id'] );
            if ( $variation && $variation->get_shipping_class() === 'heavyweight' ) {
                $has_heavy_item = true;
                break;
            }
        }
    }
    
    if ( $has_heavy_item ) {
        foreach ( $rates as $rate_key => $rate ) {
            if ( 'flat_rate' === $rate->method_id ) {
                $rates[ $rate_key ]->cost += 5.00; // Add surcharge
            }
        }
    }
    
    return $rates;
}

Add this to your theme’s functions.php or a custom plugin. This example adds a $5 surcharge when any heavyweight variation is in the cart.

Troubleshooting Common Issues

Shipping class not appearing on variations

Make sure your product type is set to “Variable product” and that you’ve created variations (not just attributes). The shipping class dropdown only appears on saved variations.

Wrong shipping cost at checkout

Check these in order: (1) Verify the correct shipping zone is matching the customer’s address. (2) Confirm the flat rate method has costs set for your shipping classes. (3) Check whether calculation type is “per class” or “per order”. (4) Clear WooCommerce transient cache via WooCommerce > Status > Tools > Clear transients.

Variation inheriting parent shipping class

If a variation shows “Same as parent”, it uses the parent product’s shipping class. To override, explicitly select a different class on the variation. This is the most common source of incorrect shipping charges.

Plugins for Advanced Shipping Class Management

Communicate Shipping Costs Clearly

Clear communication prevents cart abandonment. Display shipping estimates on product pages, create a dedicated shipping policy page explaining how rates are calculated for different product types, and use cart notices to inform customers about thresholds for free shipping.


How to Set Quantity Limits for Each Product Variation in WooCommerce

Schema Markup for WooCommerce Products

Varun Dubey

Shaping Ideas into Digital Reality | Founder @wbcomdesigns | Custom solutions for membership sites, eLearning & communities | #WordPress #BuddyPress