API V1 is no longer in active development. If you are starting a new integration, it is recommended you use API V2

Orders

The Lead Commerce Order API allows you to view, create, and update.

If you are looking for the Fulfillment extension of the Order API, click here.

Views

Views allow you to display data about your orders including line items and shipping information and more. Available output are in xml and json

Example:

<?php  
header("Content-type: text/xml;");  
$credentials = array('identifier' =>  'LC350000000', 'key'=> 'dynKSr4I7y2K3RrPRsFYFJr03IXUbv'); 
$curl = curl_init();  
curl_setopt($curl,CURLOPT_POSTFIELDS, http_build_query($credentials));  
curl_setopt($curl,CURLOPT_POST, 1);  
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v1/Orders.xml');
curl_exec($curl);  
curl_close($curl);  
?>

With orders, you can filter the result set also by the sales channel and timeframe.

<?php  
header("Content-type: text/xml;");  
$credentials = array('identifier' => 'LC350000000', 'key'        => 'dynKSr4I7y2K3RrPRsFYFJr03IXUbv',
 'sales_channel'   => 1,
 'placed_start'    => 1395334414,
 'placed_end'      => 1395336987);  
$curl = curl_init();  
curl_setopt($curl,CURLOPT_POSTFIELDS, http_build_query($credentials));  
curl_setopt($curl,CURLOPT_POST, 1);  
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v1/Orders.xml');
curl_exec($curl);  
curl_close($curl);  
?>

Please note that the filter "sales_channel" must be a sales channel ID. The placed_start and placed_end is the time parameters when the order was placed. You can use them separately or together.

Filters

Key Data Type Required Example Notes
order_status Integer No This number represents the status value. The values goes as follows:

  • 1 Quote
  • 2 Pending
  • 3 Backordered
  • 4 Partially Backordered
  • 5 Canceled
  • 7 Processing
  • 8 Partially Shipped
  • 9 Shipped
  • 10 Returned
  • 11 Pending Return
  • 12 Partially Return
customer_type Integer No 1 The ID of the Customer Type
sale_channel Integer No 6 The ID of the Sale Channel the Order belongs to
customer_id Integer No 651 The ID of a particular customer. This is the Lead Commerce ID, not Display ID
order_id Integer No 1006 The ID of a particular order
alternate_order_id String No 100020280 The Alternate Order ID
placed_start Integer No 1406239561 UNIX timestamp of when the Order was placed. This is great for a range.
placed_end Integer No 140624551 UNIX timestamp of when the Order was placed. This is great for a range.

Example Output:

<?xml version="1.0" encoding="UTF-8"?>
<message client="192.168.100.208" time="1402076250">
   <response>
      <code>200</code>
      <data>
         <item>
            <order_id>1000</display_id>
            <customer_id>1</customer>
            <sale_channel>1</sale_channel>
            <tax>0.00</tax>
            <shipping>10.00</shipping>
            <shipping_override>N</shipping_override>
            <shipping_account />
            <total>78.97</total>
            <paid>0.00</paid>
            <subtotal>68.97</subtotal>
            <line_item_total>68.97</line_item_total>
            <shipped>N</shipped>
            <placed>6/6/2014 1:32PM</placed>
            <notes />
            <status>Backordered</status>
            <name>Billy Bob</name>
            <email>billyBob@leadcommerce.com</email>
            <phone>6199900074</phone>e>
            <products>
               <product>
             <line_item>1</line_item>
                  <inventory_sku>1-0003</inventory_sku>
          <inventory_id>3</inventory_id>
                  <product_id>1</product_id>
                  <qty>1</qty>
                  <committed>0</committed>
                  <price>22.99</price>
                  <subtotal>22.99</subtotal>
                  <tax>0.00</tax>
                  <can_ship>Y</can_ship>
                  <discount_type>0</discount_type>
                  <discount_number>0.00</discount_number>
                  <total>22.99</total>
                  <status>Backordered</status>
               </product>
               <product>
             <line_item>2</line_item>
                  <inventory_sku>1-0002</inventory_sku>
          <product_id>1</product_id>
                  <inventory_id>2</product_id>
                  <qty>1</qty>
                  <committed>0</committed>
                  <price>22.99</price>
                  <subtotal>22.99</subtotal>
                  <tax>0.00</tax>
                  <can_ship>Y</can_ship>
                  <discount_type>0</discount_type>
                  <discount_number>0.00</discount_number>
                  <total>22.99</total>
                  <status>Backordered</status>
               </product>
               <product>
             <line_item>3</line_item>
                  <inventory_sku>1-0001</inventory_sku>
                  <product_id>1</product_id>
          <inventory_id>1</inventory_id>
                  <qty>1</qty>
                  <committed>0</committed>
                  <price>22.99</price>
                  <subtotal>22.99</subtotal>
                  <tax>0.00</tax>
                  <can_ship>Y</can_ship>
                  <discount_type>0</discount_type>
                  <discount_number>0.00</discount_number>
                  <total>22.99</total>
                  <status>Backordered</status>
               </product>
            </products>
            <fulfillments>
               <fulfillment>
          <fulfillment_id>27</fulfillment_id>
                  <shipping_provider_class>51</shipping_provider_class>
          <shipping_provider>5</shipping_provider>
                  <line_items>3</line_items>
                  <total_items>3</total_items>
                  <warehouse>1</warehouse>
          <customer_address>7</customer_address>
              <products>
                <product>
                <qty>1</qty>
                <line_item>1</line_item>
                <customer_address>7</customer_address>
                </product>
            </products>
               </fulfillment>
            </fulfillments>
        <payments>
        <payment>
            <payment_id>3</payment_id>
            <payment_gateway>Cash</payment_gateway>
            <payment_gateway_id>2</payment_gateway_id>
            <amount>26.80</amount>
            <customer_address>7</customer_address>
            <data1>Additional Data 1</data1>
            <data2>Additional Data 2</data2>
            <data3/>
            <data4/>
            <received>8/18/2014 1:50PM</received>
        </payment>
        </payments>
         </item>
      </data>
   </response>
</message>

Create

Create allows you to create Orders as if you went through the Lead Commerce Back Office. Refer to the Data Points table below to learn which data points can be passed when creating Orders.

Data Points

Key Data Type Required Example Notes

sales_channel

int

Yes

2


customer_type

int

yes

'Preferred'

What time of customer to create

alternate_order_id

string

No

X4545RL0

An alternative order ID.

shipping_cost

currency

yes

$15.57

Price paid for shipping

shipping_provider

int

Yes

5

ID of the shipping provider

first

string

Yes

Jack

Part of the array Customer

last

string

Yes

Jones

Part of the array Customer

phone

string

No

619.555.1212

Part of the array Customer

email

string

No

jackjones@myleadcommerce.com

Part of the array Customer

company

string

No

Jack Inc

Part of the array Customer

placed

int/string

No

Can be a UNIX timestamp (871708681) or string "8/15/1997". If not passed, it will use the current time.

Products

All product data is a subvalue under the array value "products"

Key Data Type Required Example Notes
sku string Yes 1154-8211

qty
int Yes 6 What time of customer to create
shipping_class int Yes 51 An alternative order ID.
address array Yes
See Customer Address section for values
price decimal Yes 16.58
tax decimal No 1.65

Payments

All payment data is a subvalue under the array value "payments". This will allow for payments to be made. You can use multiple payments for

Key Data Type Required Example Notes
amount decimal Yes 16.85

date
string No 6/12/2014 This will use the date of the api request if not passed.
address array No See Customer Address section for values. This address cannot be a multidimensional array
data1 string No Any Additional Notes
data2 string No Any Additional Notes
data3 string No Any Additional Notes
data4 string No Any Additional Notes
notes string No Some additional notes about this transaction Any Additional Notes

Customer Address

All payment data is a subvalue under the array value "address". This section will create the address for the customer. This is not required.

Key Data Type Required Example Notes
full_name string Yes Tom Smith Customer full name for shipping
status int/string No 1 ( or 'Active') Set address status, default to active if not set
address_1 string Yes 5000 Parkway Ave. Customer street address
address_2 string No #423 Unit/Apartment Number
city string Yes Los Angeles
subregion string Yes CA Customer state (abbr)
postal_code string Yes 90210
region string Yes United States Customer country
phone string No 310-555-9876
default_billing int No 1 Set address as default billing address
default_shiping int No 1 Set address as default shipping address

Example:

<?php  
header("Content-type: text/xml;");  
$insert = array('sales_channel'         => '1',
                'customer_type'       => 1,
                'shipping_cost'       => 10.00,
                'customer'          =>array(
                                    'first'               => "Jack",
                                    'last'                => "Jones",
                                    'phone'               => "619.555.1212",
                                    'email'               => " jackjones@myleadcommerce.com"),
                'shipping_provider'         => '5',
                'products'    => array(array('sku'    => '1000-0003',
                                              'qty'        => '1',
                                              'shipping_class'    => '51',
                                              'address' => array('full_name'         => 'Leo DeCappuccino',
                                                         'address_1'         => '5000 Parkway Avenue',
                                                         'city'              => 'Los Angeles',
                                                         'subregion'         => 'California',
                                                         'postal_code'       => '90210',
                                                         'phone'             => '310-555-6789',
                                                         'default_billing'   => 1),
                                              'price'       => '16.80',
                                              'tax'    => '0'),
                                        ),
                'payments'    => array(array('amount'    => 26.80,
                                              'data1'    => 'Additional Data 1',
                                              'data2'    => 'Additional Data 2'
                                              ),
                                        ),
                );
$credentials = array('identifier' => 'LC350000000', 'key'        => 'dynKSr4I7y2K3RrPRsFYFJr03IXUbv', 'inserts'    => array($insert)); 
$curl = curl_init();  
curl_setopt($curl,CURLOPT_POSTFIELDS, http_build_query($credentials));  
curl_setopt($curl,CURLOPT_POST, 1);  
curl_setopt($curl, CURLOPT_URL, 'http://leadcommercestore.web/api/v1/Orders.xml/create.xml');
curl_exec($curl);  
curl_close($curl);  
?>

Start your free, no-risk trial today.