General

How to get active Shipping Methods list in Magento 2

Your online shoppers deeply care about shipping costs and delivery options. Because E-commerce model is based on the idea that customers will order products online and then the item is delivered to their location wherever they reside. No matter how good your product is a good shipping system is the backbone of any successful E-commerce business. Having an effective & reliable E-commerce shipping strategy in place is one of the most impactful steps you can take to grow your business online.

By default, Magento 2 offers different shipping methods from which you can enable or disable any shipping method to fulfill your business needs. All the enabled shipping methods will be automatically listed on frontend and your customer will able to pick their convenient shipping method while checkout.

Sometimes it becomes necessary for the store owner to showcase the list of available shipping carriers to build trust among store customers and it can be anywhere. Recently one of customer came across the requirement of where he wants their customers to select their preferred shipping method from available shipping methods while the store registration process.
Here is the code to do the same.

First, we need to create a custom block file with name ‘Shippingmethods.php’ at the following location with below code.
App\code\Vendor\Extension\Block\Shippingmethods.php


Now, you just need to call getActiveShippingMethod() function into your phtml file where you want to display the list of available shipping methods. This function returns the array of active shipping methods and display it.
That’s it! If you found this blog helpful, don’t forget to share it with your colleagues and Magento Friends.
And, Let us know if you are facing an issue while implementing this code.
Happy Listing!

Click to rate this post!
[Total: 14 Average: 4.1]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

View Comments

Recent Posts

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

2 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

4 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

4 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

5 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

6 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

1 week ago