4

I am using the gabrielbull ups api wrapper and it is working fine, except when I want to add an UPS access point; the documentation says 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 on 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);

Edit: I got this info of setting up the accesspoint from UPS support. The guy told me to set an alternate address with the AccessPoint data that will be printed at the bottom line of the label (where it's currently missing). If I misunderstood something (though we did a video conference and he showed me the result) and you know another way, feel free to tell me.

Insomnia88
  • 378
  • 2
  • 13
  • What errors are you expecting to receive that you do not? If it is working, should you not receive exactly 0 errors? – zbee Aug 07 '19 at 19:17
  • From some cursory research on UPSs API the only mentions I can find of alternate addresses would be from their address validation providing them in the event that the address provided could not be verified. Can you share the error you were receiving in the first place? Can you also share the documentation specifying you need the alternate address? – zbee Aug 07 '19 at 19:20
  • I am not getting and expecting errors - that's why it's do difficult for me. As I wrote I want to print a UPS label and that's where the main problems lies. If I add all the data including the code above with an alternative address and print the $shipment variable everything is in it's place - at least as far as I can tell. BUT when you print a UPS label the alternatie address part is missing. I talked to a service worker of UPS and he told me that I have to use the alternate address for declaring an access point. It will then be printed on the bottom line of the label. But it's missing there. – Insomnia88 Aug 11 '19 at 18:15
  • That is a long shot because I'm not familiar with UPS API, but just to check, you are doing a setAlternateDeliveryAddress method on the $shipment object providing what looks like an address object, but you're not doing anything like that with your main $address ? Could it be that the alternate address fall back as the main address because the main address is not defined in $shipment ? – François Huppé Aug 11 '19 at 18:56
  • The main address is defined, I just didn't include the whole code. The code above is only the part that I set for the access point. – Insomnia88 Aug 11 '19 at 19:14
  • Is your `$ap_id` a valid ID? – Moses Schwartz Aug 13 '19 at 02:53
  • @Moses Yes it is – Insomnia88 Aug 13 '19 at 08:24

1 Answers1

1

Ok after re-reading the official docs I found out what was missing. If you want to use an accesspoint as address you also have to set the Indication Type via setShipmentIndicationType. There are 2 codes: 01 and 02 depending on the way you want to send it. Ofcourse I didn't add them before...

I haven't finished it yet because I get some errors but that's more about what information ups needs from me and so on. At least I can work with that.

As I mentioned in my initial post I used the example of the api wrapper as base and insert the required part before the request was send:

...
// Set Reference Number
...

// this is the part where you set shipment indication type for the accesspoint
$accesspoint = new \Ups\Entity\ShipmentIndicationType;
$accesspoint->setCode(Ups\Entity\ShipmentIndicationType::CODE_HOLD_FOR_PICKUP_ACCESS_POINT); // for "01" 
#$accesspoint->setCode(Ups\Entity\ShipmentIndicationType::CODE_ACCESS_POINT_DELIVERY); // for "02"
$shipment->setShipmentIndicationType($accesspoint);

// Set payment information
...

// Ask for negotiated rates (optional)
...


// Get shipment info
...
Insomnia88
  • 378
  • 2
  • 13
  • post your code, which going to help other ones with finding solution to this question. – Serghei Leonenco Aug 14 '19 at 05:32
  • I did but in my case it's not yet complete because I still have some problems with phone/email validation of the alternate address above. I am in contact with the ups support and will add it later when I know more – Insomnia88 Aug 14 '19 at 06:49