I have a special case where I want to show all active shipping methods with applied estimated shipping cost to login customer if customer has default shipping address set in address book.

The following link describe how to show all active shipping methods in a custom module.

Magento 2 How to get all active shipping methods?

But I did not find any code that also display shipping rate of each method. So I need to show shipping rate of each shipping method to login customer. These customer already has some shipping address.

1 Answer 1


I just create some code hopefully its help u.

create test.php on your project root directory.

require __DIR__. '/app/bootstrap.php'; 

require __DIR__.'/TestApp.php';

$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager(); /** @var
\Magento\Framework\App\State $state */ $state =

/** @var \Magento\Framework\App\Http $app */ $app =


Then create TestApp.php on your project root directory.

use Magento\Shipping\Model\Config\Source\Allmethods;

class TestApp extends \Magento\Framework\App\Http implements
\Magento\Framework\AppInterface {

    public function launch() {
        /** @var \Magento\Shipping\Model\Config\Source\Allmethods $allmethods */
        $allmethods = $this->_objectManager->get(Allmethods::class);


        return $this->_response;

  • $allmethods->toOptionArray() only return shipping methods, I need shipping rates of each method also, and I am stuck on how to get shipping rates along with shipping methods Mar 14, 2018 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.