I have a magento based website, that requires additional custom shipping method. The shipping cost will be calculated by sending the origin and destination details to an API and it will returns with the calculated rates.
1. Create a custom shipping method.
2. On checkout page first allow user to select country from country dropdown. When user select country call an api to get list of states of this country using ajax. When user select state, allow user to select city from city dropdown. This city dropdown should be filled up from api using ajax.
3. When customer select city from dropdown, first check in custom database table if we have rates available for same source and destination. If we do not have then call an api and get rates for this source and destination and store in db table.
Note: This module will work only for Indonesia country as api has states and cities available for this country only. Also that db table will be empty initially so as orders are being placed\
that table will be getting filled up.
My site will be a marketplace based, meaning the origin will be the location of the merchant. If cart has more than one merchant products then it needs to sum up all shipping rates. From the API it will get two rates for each request.