Place Order Function

The function to place an order is PlaceOrder.

Request

creds (type: array)
Credentials must be passed in the order data to authenticate (see authentication for more details)
  • Credentials.partnerCode (type: string)
    Your unique partner key as assigned by ZenPrint
  • Credentials.apiKey (type: string)
    Your unique API key as assigned by ZenPrint
partnerOrderId (type: int)
This is your order number, used to check the order status
rushOrder (type: boolean)
not implemented yet. This should be set to 0, unless otherwise instructed by ZenPrint
orderDate (type: date)
This is your order date, used for your own internal tracking
orderLineItems (type: array)
This is an array of line items to be ordered
  • LineItem.lineItemId (type: int)
    The unique line number of the item ordered (usually the 1st item is 1, 2nd item is 2, etc.)
  • LineItem.productType (type: string)
    This should be set to PARTNER, unless otherwise instructed by ZenPrint
  • LineItem.productId (type: int)
    This is the product ID provided by ZenPrint for the type of product you want to order
  • LineItem.projectId (type: int)
    This should be set to 0, unless otherwise instructed by ZenPrint
  • LineItem.quantity (type: int)
    The quantity of the item to be ordered
  • LineItem.files (type: array)
    This is an array of files for printing.
    • File.FileId (type: string)
      This should be set to one of these 3 types of file components for the product being ordered COVER, GUTS or FULL
    • File.FileFormat (type: string)
      This should be set to PDF, unless otherwise instructed by ZenPrint
    • File.FileName (type: string)
      This should be the URL location of the file on Amazons S3 service or similar web accessible URL.
      The files naming convention should be formatted partnerOrderId-lineItemId-FULL.pdf for single file products.
      Multi-file products (like books) should be formatted partnerOrderId-lineItemId-GUTS.pdf & partnerOrderId-lineItemId-COVER.pdf. (The "GUTS" and "COVER" parts of the filename should be capitalized).
  • LineItem.shippingData (type: array)
    This is an array of shipping information for the line item. This information will typically be the same for each line item, except in the case of direct mail products.
    • carrier (type: string)
      Shipping carrier should be set to either USPS or UPS
    • shipMethod (type: string)
      This is the shipping method. Use the table below for the correct shipping codes.
      • USPS First Class Mail: 1C
      • USPS First Class International Mail: IFC
      • USPS Priority Mail: PR
      • USPS Priority Mail International: 1P
      • USPS Direct Mail: USPS-D (this method is restricted to certain products only. Contact us for more details)
      • USPS Media Mail: MM (this method is restricted to certain products only. Contact us for more details)
      • UPS Ground: GR
      • UPS 2nd Day Air: 2D
      • UPS Next Day Air: 1D
    • shipAddress (type: array)
      This is the shipping address for the line item.
      • ShipToAddress.name (type: string)
        The name of the recipient
      • ShipToAddress.company (type:string - not required)
        The name of the recipient company
      • ShipToAddress.address1 (type:string)
        The street address of the recipient
      • ShipToAddress.address2 (type:string - not required)
        Additional street address of the recipient
      • ShipToAddress.city (type:string)
        The city of the recipient
      • ShipToAddress.state (type:string)
        The 2-digit state code for shipments to the USA. Accepts provience names or abbreviations for all other countries.
      • ShipToAddress.zipCode (type:string)
        The postal code of the recipient.
      • ShipToAddress.countryCode (type:string)
        The 3-digit country code of the recipient
      • ShipToAddress.emailAddress (type:string - not required)
        The email address of the recipient
      • ShipToAddress.mainPhone (type:string - not required)
        The phone number of the recipient
      returnAddress (type: array - not required)
      Only required for direct mail pieces to print a return address on the mailing
      • ReturnAddress.name (type: string)
        The name of the recipient
      • ReturnAddress.company (type:string - not required)
        The name of the recipient company
      • ReturnAddress.address1 (type:string)
        The street address of the recipient
      • ReturnAddress.address2 (type:string - not required)
        Additional street address of the recipient
      • ReturnAddress.city (type:string)
        The city of the recipient
      • ReturnAddress.state (type:string)
        The 2-digit state code for shipments to the USA. Accepts province name or abbreviation for all other countries.
      • ReturnAddress.zipCode (type:string)
        The postal code of the recipient.
      • ReturnAddress.countryCode (type:string)
        The 3-digit country code of the recipient
      • ReturnAddress.emailAddress (type:string - not required)
        The email address of the recipient
      • ReturnAddress.mainPhone (type:string - not required)
        The phone number of the recipient
  • LineItem.lineItemUpgrades (type: array - not required)
    These are product specific upgrade options (see product specification for more information)
    • UpgradeData.upgradeId (type: int)
      This is the ID assigned to the specific product upgrade option.

Response

OrderData.receivedTimeStamp (type: datetime)
This is the date we received the order
OrderData.LineItem (type: array)
This is an array of the orders line items and their current state
  • LineItem.currentState (type: array)
    The current status of the line item. Can include:
    • PENDING - The order is received and waiting to be printed
    • HOLD - The order is on hold due to an issue
    • CANCELLED - The order is cancelled
  • LineItem.currentStateTimeStamp (type: datetime)
    The date and time the item moved to its current state
OrderData.errors.message (type: string)
Any errors in the submission will be returned here

Sample Code (PHP)

<?php // * Place an Order *

//showing all errors
error_reporting(E_ALL);
ini_set('display_errors', '1');

$client = new soapclient('http://orderapi.zenprint.com/orderapi/?WSDL', array('cache_wsdl' => WSDL_CACHE_NONE));
$credentials = array("partnerCode"=>"REPLACE_WITH_PARTNER_CODE", "apiKey" =>"REPLACE_WITH_API_KEY");

$orderLines = array(); //setup an array to contain your order line items

// * start line item area * (you may need to loop this section if you have multiple line items)

$shipToAddress = array(
	"name"=>"John Doe",
	"address1"=>"555 Main Street",
	"address2"=>"Suite 100",
	"city"=>"Provo",
	"state"=>"UT",
	"zipCode"=>"84606",
	"countryCode"=>"USA",
	"emailAddress"=>"john@example.com",
	"mainPhone"=>"555-555-5555"
);

$shippingInfo = array(
	"shipAddress"=>$shipToAddress,
	"carrier"=>'USPS',
	"shipMethod"=>"PR", //see the shipping codes section below for more info
	"returnAddress"=>""
);	

$file=array(
	"FileFormat"=>"PDF",
	"FileName"=>"https://zenprint.s3.amazonaws.com/zenprint/temp/pdfs/12345-1-FULL.pdf"
);

$lineitem = array(
	"lineItemId"=>1, //this should be unique (1 for first item, 2 for second item ordered, etc.)
	"productId"=>27, //this is the product you're wanting to order
	"projectId"=>0, //pass 0 for this unless otherwise instructed
	"productType"=>"PARTNER", //pass PARTNER for this unless otherwise instructed
	"quantity"=>1,
	"files"=>array($file),
	"shippingData"=>$shippingInfo
);

array_push($orderLines, $lineitem); //add the line item to your orderLines array

// * end line item area *

//set up today's date
$s = date("m/d/Y, H:i:s");
$date = strtotime($s);

$order = array(
	"creds"=>$credentials, //see the section on authentication for this
	"partnerOrderId"=>"12345", //you can pass your own order number if you have one
	"orderLineItems"=>$orderLines,
	"rushOrder"=>0,
	"orderDate"=>$date,
	"errors"=>"" //just pass an empty string for this
);

//var_dump($order);

$newOrder = $client->PlaceOrder(array("orderData" => $order));
?>
Application: ZenPrintApp [Run Tests, View Tests]
Framework: CFWheels 1.4.4
Active Environment: Development
Host Name: utpspro2
CFML Engine: Adobe ColdFusion 9,0,1,274733
Default Data Source: Zenprint
Database Adapter: SQLServer
URL Rewriting: On
URL Obfuscation: Off
Plugins: None
Controller: Main
Action: ApiPlaceOrder
Parameters: None
Execution Time: 31ms (beforefilters ~16ms, view ~15ms, action ~15ms)
Help Links: Documentation, Mailing List, Issue Tracker