2

I want to hide fedex and usps shipping methods for some states. I am trying to get the selected state in the getShippingMethods functions which returns the avaialable shipping methods. This function is in ShippingMethodManagement class.

I tried getting region id by $shippingAddress->getRegionId() but it just returns the default shipping address state, not the selected one.

I also tried getting the region id using checkout session but same result.

If anyone have the solution for this, please share.

thanks

  • Related question: I want to hide free shipping for specific state like Alaska, Hawaii etc. – Masuk Jun 25 at 17:11
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – Shoaib Munir Jun 25 at 17:55
1

In case anyone else get into the same issue. I was getting shipping address from quote and the session, which was returning me default address.

Today i checked the function again private function getShippingMethods(Quote $quote, $address) and the answer was in its 2nd parameter.

$address->getRegionId() contains the selected state id.

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.