I am trying to accomplish the following. I need to be able to add a custom shipping module that grabs shipping costs from an external system through an API.

Once a customer gets to the point of shipping costs, magento would send product information (weight, cost) through the API and the result would return the shipping costs for the order.

If anyone has dealt with anything similar, I would really appreciate any help that you can give me.

Thank You in advance!


  • you have to create a Custom Shipping module and in that model file you have to call the exrnal API and based on that bind the price of this shipping method
    – Keyul Shah
    Aug 21 '14 at 4:55
  • Thanks for the response Keyul. What I am trying to do is create an API with the outside database. So, I pratically need to use the Magento API to connect to the external database and calculate the shipping costs while staying on the website. So, as far as the customer is concerned, the shipping cost is being calculated by the website itself.
    – branimalus
    Aug 22 '14 at 15:12
  • Then its not necessary to create api for that external database. Beacuse in magento you conntect that database do what u want based on price will pass in that curom dhipping method.
    – Keyul Shah
    Aug 23 '14 at 1:24
  • I cannot access the system directly. Instead, I need to connect to it using SOAP and call the external system to calculate the cost and return a value and place it into the shipping cost. So, I am not directly accessing the database, but the system that calculates the value. I would need to send some parameters regarding the shipment (value, weight) to the external shipment which would return the shipping value accordingly. Would you have any suggestions? Thank You,
    – branimalus
    Aug 25 '14 at 3:44

Here is an example on how to create a shipping method.
Now all you need to do is to call your API inside the collectTotals method and retrieve the price instead of filling in a default price.

You can get the items in order to send them through the APi by calling $request->getAllItems(). You can get the total weight of the order with $request->getPackageWeight(), you can get the total price with $request->getPackageValue() or $request->getPackageValueWithDiscount().

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.