Skip to main content
3 of 3
added 12 characters in body
Amit Bera
  • 77.7k
  • 20
  • 124
  • 239

Magento\Quote\Model\Quote\Address\RateRequest is work fine when we calculating shipping method.

Understand how the Shipping address is saved & shipping methods are calculated at checkout.

At checkout steps, when a user enters shipping country Or Shipping region or Selecting an existing then an ajax request happen which is take address fields data from Shipping Address form and set address data to Magento\Quote\Model\Quote\Address\RateRequest object and which used all shipping methods for calculating the shipping cost and it's availability . But request does not save the address to the Database table quote_addrss.

So, in that request, if you use Magento\Quote\Model\Quote\Address\RateRequest then you will get right $request->getDestCountryId() etc.

But Shipping Address is saved when we select a shipping method at the checkout by click on Next button. that time's ajax does not request shipping cost calculation method, So if use Magento\Quote\Model\Quote\Address\RateRequest on that time , on your code that does not give right address details.

Magento\Quote\Model\Quote\Address\RateRequest is only working fine when you shipping method is calculated.

Update

use $request->getDestRegionCode() getting Region field data. Take look on method \Magento\Customer\Model\Address\AbstractAddress::getRegionCode()

Amit Bera
  • 77.7k
  • 20
  • 124
  • 239