0

How can we get the shipping method code from the Payment Module to, activate/deactivate payment method based on selected shipping method?

1 Answer 1

1

To get current shipping method in magento 2 you need to create object instance for Magento\Checkout\Model\Cart

Use following code to get shipping method of current quote

$om =   \Magento\Framework\App\ObjectManager::getInstance();
$cartData = $om->create('Magento\Checkout\Model\Cart')->getQuote()
           ->getShippingAddress()->getShippingMethod();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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