Reputation: 1660
I've been able to create a shipment and add a tracking number via SOAP, but I'm stuck figuring out how to email the customer their tracking number through the API. When creating a shipment I can send out an email, but a shipment has to be created before I can add a tracking number. I realize I can create my own email and send it out, but I'd rather stick to the API if possible.
Is there a SOAP method I can use to do this?
Creating the tracking number:
public function addTrackingNumber($trackingNumber)
{
$shipmentID = $this->createShipment();
return $this->client->salesOrderShipmentAddTrack(
$this->sessionId,
$shipmentID,
"ups",
"UPS",
$trackingNumber
);
}
Upvotes: 3
Views: 1473
Reputation: 414
The shipment API has an undocumented sendInfo
endpoint. I'm not sure when it was added, so it may not be in your version of Magento, but you can look for it in app/code/core/Mage/Sales/Model/Order/Shipment/Api.php
. In Magento 1.9.1.0 it looks like this:
public function sendInfo($shipmentIncrementId, $comment = '')
You'll need to work backwards from this to get the right code for the version of the API you're using. Here's what my request looks like (V1):
$result = $client->call($session, 'sales_order_shipment.sendInfo', array('100000001', 'an optional comment'));
In your application I suspect it would look something like this:
return $this->client->salesOrderShipmentSendInfo($shipmentID, 'an optional comment');
So you'll need to make three API calls: first to create the shipment (not sending the notification email), second to add the tracking number, and third to finally send the notification.
Upvotes: 2