Wednesday, 7 August 2019

how to set alternative address in ups api wrapper?

I am using the gabrielbull ups api wrapper (https://github.com/gabrielbull/php-ups-api) and it working fine except when I want to add an ups access point. The docs say I have to declare a "AlternateDeliveryAddress". The access point data should then be printed on the ups label but they are not appearing.

Since there isn't an example for this case at the wrapper github page I searched for methods on my own and found one but I have the feeling I forgot something since I don't receive any errors. I tried this code for the specific part. The surrounding code is like in the shipping class example

$address = new \Ups\Entity\Address();
$address->setAddressLine1($ap_addressline1);
$address->setPostalCode($ap_postal);
$address->setCity($ap_city);
$address->setCountryCode($ap_country);
$alternateTo = new \Ups\Entity\AlternateDeliveryAddress;
$alternateTo->setAddress($address);
$alternateTo->setUpsAccessPointId($ap_id);
$alternateTo->setName($ap_name);
$alternateTo->setAttentionName($ap_name);
$shipment->setAlternateDeliveryAddress($alternateTo);



from how to set alternative address in ups api wrapper?

No comments:

Post a Comment