Hello magento friends todays in this blog post im share with you to How to Get Shipping Rates by Quote ID in Magento 2. In Magento 2, you can retrieve the shipping rates by Quote ID using the following steps:
➤ Create a custom module:
First, you need to create a custom module in Magento 2 if you haven't already done so. If you're not familiar with creating Magento 2 modules, you can refer to the official documentation or tutorials for guidance.
➤ Inject the necessary dependencies:
In your custom module, you'll need to inject some classes to access the shipping rate information. Add the following code to the constructor of your custom class:
➤ Retrieve shipping rates by Quote ID:
Now, you can create a method in your custom class to get the shipping rates based on the Quote ID:
➤ Using the method to get shipping rates:
Now, you can use this method in your code wherever you have the Quote ID available. For example, in a controller or a block:
Replace 'YOUR_QUOTE_ID' with the actual Quote ID you want to retrieve the shipping rates for. The $shippingRates variable will contain an array with available shipping rates for the given Quote ID.