How to get carrier by "shipping method" in magento

How to get carrier by "shipping method" in magento

July 17, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to get carrier by "shipping method" in magento

Binding Carriers to Shipping Methods in Magento

Hello developers! Today we’re going to explore how to tie your shipping carriers to their respective methods within Magento’s robust e-commerce platform.

Understanding the Hierarchy: Carrier vs. Method

Before diving into the code, let me clarify some terminology:

  1. Carrier: This is the actual carrier company (e.g., UPS, DHL, FedEx) that you’ve integrated with your store.
  2. Method: Each carrier can offer multiple shipping options or methods. For example, UPS might provide services like Ground, Next Day Air, and Express.

Identifying Your Shipping Method

You mentioned your order has a shipping method of “flatrate_flatrate”. Let’s break this down:

  • flatrate: This is the carrier ID.
  • _flatrate: This indicates that it’s a flat rate method provided by the flatrate carrier.

Retrieving Carrier Details via Magento API

Magento provides an extensive set of APIs to interact with your store data. To fetch details about our flatrate carrier, we can use the following endpoint:

/rest/V1/carriers

You’ll need to authenticate using a token generated in your admin panel. The response will look something like this:

[
    {
        "carrier_id": "flatrate",
        "name": "Flat Rate"
        // Other fields...
    }
]

Understanding Flat Rate Configuration

In our case, flatrate is actually a built-in Magento carrier type called Flat Rate. This carrier allows you to set a flat fee for shipping, regardless of the package weight or destination.

To configure this carrier:

  1. Navigate to Stores > Settings > Configuration.
  2. Select the desired store view.
  3. In the left menu, choose Sales > Shipping Methods.
  4. Expand the Flat Rate section and enable it by setting Enabled to Yes.
  5. Set your fixed shipping price in the Fixed field.

Binding the Carrier and Method

In Magento, carriers and their methods are tied together via the configuration file located at:

app/code/core/Mage/Shipping/etc/config.xml

For our flat rate carrier, you’ll find this snippet inside the <config> tag:

<flatrate>
    <title>Flat Rate</title>
    <active>1</active>
    <sphere_model>carrier/flatrate_spherical</sphere_model>
    <specific_error_model>carrier/flatrate_specificerror</specific_error_model>
    <method>
        <weight>0.5</weight>
        <price>0</price>
        <model>carrier/flatrate_fixed</model>
        <fee_per_order>0.00</fee_per_order>
        <handling_type>F</handling_type>
        <handling_fee>0.00</handling_fee>
    </method>
</flatrate>

As you can see, the flatrate carrier is associated with a single method in its configuration file. This method has a fixed price of 0 and handles all orders.

Conclusion

Binding carriers to shipping methods in Magento is a crucial step when setting up your shipping options. By correctly configuring these elements in your admin panel and understanding how they relate behind the scenes, you’ll ensure that customers have accurate shipping quotes at checkout.

Remember, for more complex integrations or custom carrier setups, consider exploring the rich ecosystem of extensions available from trusted providers like https://laravelcompany.com. They offer advanced solutions to enhance Magento’s built-in features while keeping your store secure and performant.

Happy coding!

API Admin Configuration Orders

Our network