• Resolved yourbudweiser

    (@yourbudweiser)


    Hello, I am trying to add a shipping method to an order by using the FedEx Shipping Method ID.

    $order = wc_get_order( $order_id );
    
    $item = new WC_Order_Item_Shipping();
    $item->set_method_title( "FedEx Ground" );
    $item->set_method_id( "fedex:11:FEDEX_GROUND" );
    $item->set_total( $new_ship_price ); // (optional)
    $item->calculate_taxes($calculate_tax_for);
    
    $order->add_item( $item );
    $order->calculate_totals(); 

    But this is not giving me the FedEx Ground rate, it’s giving me the FedEx Standard Overnight rate.

    By inspecting the value of the Shipping methods on the Checkout page, I can see:

    <input type="radio" name="shipping_method[0]" data-index="0" id="shipping_method_0_fedex11fedex_ground" value="fedex:11:FEDEX_GROUND" class="shipping_method">

    Is there some other way to get the shipping method ID for the FedEx rates?

Viewing 1 replies (of 1 total)
  • Hi @yourbudweiser

    Thanks for reaching out!

    I understand that you are using the code snippet above to add a shipping method to an order by using the FedEx Shipping Method ID, however, it is not giving you the FedEx Ground rate, instead it gives the FedEx Standard Overnight rate, correct?

    This is a bit of a complicated topic that would need some customization to address. Unfortunately, custom coding is not something we can assist with directly. However, I’ll keep this thread open for a bit to see if anyone from the community can lend a hand.

    If you have any other questions related to development or custom coding, don’t hesitate to reach out to some of the great resources we have available for support. The WooCommerce community is filled with talented open-source developers, and many of them are active on the channels listed below:

    Hope this helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Get FedEx Shipping Method IDs’ is closed to new replies.