Call us now on 0115 9738074

Magento Q&A: How to ship orders via the API?

Difficulty: Easy

Q:

I want to mark orders as shipped after we import the shipping feed from our warehouse. Is there an API for this? Or do I have to use the actual classes?

A:

Yes, of course! You can use the shipment API, to which you can connect using both SOAP and XML-RPC. The call that will be of most interest to you is shipment.create.

Here’s the sample code from magento’s site [php]:

$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$notShipedOrderId  = '100000003';
 
// Create new shipment
$newShipmentId = $proxy->call($sessionId, 'sales_order_shipment.create', array($notShipedOrderId, array(), 'Shipment Created', true, true));

And here are the comments:

sales_order_shipment.create

Create new shipment for order

Return: string – shipment increment id

Arguments:

string orderIncrementId – order increment id

array itemsQty – items qty to ship as associative array (order_item_id ⇒ qty)

string comment – shipment comment (optional)

boolean email – send e-mail flag (optional)

boolean includeComment – include comment in e-mail flag (optional)

Share and Enjoy:
  • Facebook
  • Digg
  • del.icio.us
  • StumbleUpon
  • Google Bookmarks

Tags: , , , ,

Leave a Reply