gabrielbull / php-ups-api

PHP Wrapper for all UPS API
MIT License
456 stars 255 forks source link

Shipment Email Notifications #235

Closed tux2k47 closed 4 years ago

tux2k47 commented 5 years ago

Hi,

I figured out most of the API but I can't seem to get email notifications working for label created and delivered. Any suggestions on what I can do to enable email notifications? I'm assuming I need to specify an emailTo but I can't see to locate that. I figured out I most likely need #6 but don't know where to put the email address:

//Set Delivery Confirmation
    $DeliveryConfirmation = new \Ups\Entity\Notification();
    $DeliveryConfirmation->setNotificationCode(6);

Thanks!

bmaggot commented 5 years ago

Not exactly. It's like this:

` $shipmentServiceOptions = new \Ups\Entity\ShipmentServiceOptions(); $notificationemail[] = 'email';

$notification1 = new Ups\Entity\Notification();
$emailmessage1 = new Ups\Entity\EmailMessage(); 
$notification1->setNotificationCode("6");
$emailmessage1->setEmailAddresses($notificationemail);
$notification1->setEmailMessage($emailmessage1);
$shipmentServiceOptions->addNotification($notification1);

$notification2 = new Ups\Entity\Notification();
$emailmessage2 = new Ups\Entity\EmailMessage();
$notification2->setNotificationCode("7");
$emailmessage2->setEmailAddresses($notificationemail);
$notification2->setEmailMessage($emailmessage2);
$shipmentServiceOptions->addNotification($notification2);

$notification3 = new Ups\Entity\Notification();
$emailmessage3 = new Ups\Entity\EmailMessage();
$notification3->setNotificationCode("8");
$emailmessage3->setEmailAddresses($notificationemail);
$notification3->setEmailMessage($emailmessage3);
$shipmentServiceOptions->addNotification($notification3);   

$shipment->setShipmentServiceOptions($shipmentServiceOptions);`

Codes are in /Entity/Notification.php

gromet commented 5 years ago

Found an issue with the length of Email Memo. The Email Memo length can be 150 chars, not only 50 chars in my ups xml developer guide. In EmailMessage.php Line 184 (function setMemo)