Satyendra Mishra
Satyendra Mishra

Reputation: 533

magento ups shipping api

I want to calculate shipping rate using UPS api in magento.

I will pass lenght, width, height and zipcode the UPS api will return shipping rate for that product.

I got the UPS rating API that will calculate the shipping rate from the below url after you login.

https://www.ups.com/upsdeveloperkit/downloadresource?loc=en_US

The development guide shows we can implement this using xml or SOAP call.

Can anyone tell me how exactly can I implement this in magento if possible explain it at coding level.

Upvotes: 0

Views: 3192

Answers (1)

Michael Leiss
Michael Leiss

Reputation: 5670

You dont need to code your own api access. Just use the ootb UPS core extension.

  1. Goto class Mage_Usa_Model_Shipping_Carrier_Ups
  2. Goto line 907 (something like that) and change the part from
<Package>
  <PackagingType><Code>{$params['48_container']}</Code></PackagingType>
  <PackageWeight>
     <UnitOfMeasurement><Code>{$r->getUnitMeasure()}</Code></UnitOfMeasurement>
    <Weight>{$params['23_weight']}</Weight>
  </PackageWeight>
</Package>

to

<Package>
  <PackagingType><Code>{$params['48_container']}</Code></PackagingType>
    <Dimensions>
              <UnitOfMeasurement>
                  <Code>CM</Code>
              </UnitOfMeasurement>
              <Length>30</Length>
              <Width>30</Width>
              <Height>30</Height>
  </Dimensions>
  <PackageWeight>
     <UnitOfMeasurement><Code>{$r->getUnitMeasure()}</Code></UnitOfMeasurement>
    <Weight>{$params['23_weight']}</Weight>
  </PackageWeight>
</Package>

Just use some variables to change 30 to whatever you want. It works, i tried it!

Good luck!

Upvotes: 0

Related Questions