I am working on shopping cart custom shipping method. I am using the following link http://inchoo.net/magento-2/creating-a-shipping-method-in-magento-2/.

estimate-shipping-method ajax call having region_id and I need that value inside collectRates() method.


If you var_dump($request->getData()) you will see that there are all details available in it. To get region_id simply use,

$regionId = $request->getData('region_id');
| improve this answer | |

I found solution for it.


It gives the region id.

| improve this answer | |
$data = json_decode(file_get_contents('php://input'), true);
$region = $data['region_id'];

this is uncommon way, but it works

| improve this answer | |

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.