Use Case: Multiple Shipping Methods per Order

This case is possible with FedEx WooCommerce Shipping with Print Label. All you need is the following free add-ons and the code below.

  • Hide WooCommerce Shipping Methods based on Shipping Class and Zones
  • Skip Shipping calculation based on WooCommerce Shipping Class

These free plugins as well as, a similar case is already explained very well in the following documentation-
WooCommerce Shipping – FedEx Live Rate Adjustment based on Shipping Classes.

Here is the code that you need to add to your functions.php file…

/**
 * Snippet to Add an Additional Cost to the Shipping Service based on Shipping Class
 * Created on 28 March 2019
 * PluginHive Plugins: https://www.pluginhive.com/plugins/
**/

add_filter( 'woocommerce_package_rates', 'adjustment_in_rates_of_product_with_shipping_class', 12, 2 );

function adjustment_in_rates_of_product_with_shipping_class( $available_shipping_methods, $package ) {

   // Shipping class slug that need to add extra cost
    $shipping_class = array(
        'other',
    );

   // Give here Extra Cost you want add
    $extra_cost = 100;

    // Enter the Shipping Method Value
    $shipping_services = array(
       'wf_shipping_ups:01',
       'wf_shipping_ups:02',
       'wf_shipping_ups:03',
       'wf_shipping_ups:07',
       'wf_shipping_ups:08',
       'wf_shipping_ups:11',
       'wf_shipping_ups:12',
       'wf_shipping_ups:13',
       'wf_shipping_ups:14',
       'wf_shipping_ups:59',
       'wf_shipping_ups:54',
       'wf_shipping_ups:65',
       'wf_shipping_ups:92',
       'wf_shipping_ups:93',
       'wf_shipping_ups:94',
    );

    $shipping_class_exists = false;
    foreach(WC()->cart->get_cart_contents() as $key => $values) {
        if ( in_array($values['data']->get_shipping_class() , $shipping_class) ) {
            $shipping_class_exists = true;
            break;
        }
    }

    if ($shipping_class_exists) {
        foreach ($available_shipping_methods as $key => $value) {
            if ( in_array($value->get_id() , $shipping_services) ) {
                $available_shipping_methods[$key]->cost += $extra_cost;
            }
        }
    }

    return $available_shipping_methods;
}

If you have any more query you can leave a comment.