To add an order to a store, first instantiate a new order object with the store's API key and an associative array of the order data. A comprehensive list of the data attributes and their definitions can be found here. Then simply call the create() method.
<?php
$order = new ShippingEasy_Order("dc51f121e5ede4c163739c8dad4f98",
array("external_order_identifier" => "390049",
"subtotal_including_tax" => "12.38",
"ordered_at" => "2018-09-24",
"notes" => "Here is the customer note",
"internal_notes" => "Here is the internal note",
"discount_amount" => "2.38",
"custom_1" => "Custom Field 1",
"custom_2" => "Custom Field 2",
"custom_3" => "Custom Field 3",
"total_including_tax" => "12.63",
"total_excluding_tax" => "10.00",
"discount_amount" => "0.00",
"coupon_discount" => "0.00",
"subtotal_including_tax" => "12.63",
"subtotal_excluding_tax" => "10.00",
"subtotal_tax" => "0.00",
"total_tax" => "0.00",
"base_shipping_cost" => "2.63",
"shipping_cost_including_tax" => "2.63",
"shipping_cost_excluding_tax" => "2.63",
"shipping_cost_tax" => "0.00",
"recipients" => array(
array(
"first_name" => "Jack",
"last_name" => "Ship",
"company" => "ShippingEasy",
"email" => "[email protected]",
"phone_number" => "855-202-2275",
"residential" => "true",
"address" => "3700 N Capital of Texas Hwy",
"address2" => "Ste 550",
"province" => "",
"state" => "TX",
"city" => "Austin",
"postal_code" => "78746",
"postal_code_plus_4" => "0036",
"country" => "US",
"shipping_method" => "Ground",
"items_total" => "1",
"line_items" => array(
array(
"item_name" => "Pencil Holder",
"sku" => "9876543",
"bin_picking_number" => "7",
"unit_price" => "1.30",
"total_excluding_tax" => "1.30",
"price_excluding_tax" => "1.30",
"weight_in_ounces" => "10",
"product_options" => array(
"pa_size" => "large",
"Colour" => "Blue"
),
"quantity" => "1"
)
)
)
)
));
$res = $order->create();
?>
If successful the call will return a JSON hash with the ShippingEasy order ID, as well as the external order identifier originally supplied in your call.
{ "order" => { "id" => "27654", "external_order_identifier" => "ABC123" } }
Possible Exceptions
ShippingEasy_AuthenticationError
Your credentials could not be authenticated.
ShippingEasy_InvalidRequestError
The order could not be created on the server for one or more of the following reasons:
- The JSON payload could not be parsed.
- One or more of the supplied data attributes failed validation and is missing or incorrect.
- An order with the supplied external_order_identifier already exists for that store.
The exception will contain a message that indicates which of these conditions failed.
Order Attributes
The following is a list of attributes that should be provided to the ShippingEasy_Order
object as a associative array.
An example associative array for the create order API call may be found here: https://gist.github.com/twmills/8711096.
external_order_identifier
: Required. The e-commerce system's order ID.
ordered_at
: Required. Timestamp when the order was created.
order_status
: Possible values are "awaiting_shipment", "awaiting_payment", "awaiting_fulfillment", "awaiting_shipment", "partially_shipped". Default is "awaiting_shipment".
total_including_tax
: Defaults to 0.0 if not specified.
total_excluding_tax
: Defaults to 0.0 if not specified.
discount_amount
: Defaults to 0.0 if not specified.
coupon_discount
: Defaults to 0.0 if not specified.
subtotal_including_tax
: Defaults to 0.0 if not specified.
subtotal_excluding_tax
: Defaults to 0.0 if not specified.
subtotal_tax
: Defaults to 0.0 if not specified.
total_tax
: Defaults to 0.0 if not specified.
base_shipping_cost
: Defaults to 0.0 if not specified.
shipping_cost_including_tax
: Defaults to 0.0 if not specified.
shipping_cost_excluding_tax
: Defaults to 0.0 if not specified.
shipping_cost_tax
: Defaults to 0.0 if not specified.
base_handling_cost
: Defaults to 0.0 if not specified.
handling_cost_excluding_tax
: Defaults to 0.0 if not specified.
handling_cost_including_tax
: Defaults to 0.0 if not specified.
handling_cost_tax
: Defaults to 0.0 if not specified.
base_wrapping_cost
: Defaults to 0.0 if not specified.
wrapping_cost_excluding_tax
: Defaults to 0.0 if not specified.
wrapping_cost_including_tax
: Defaults to 0.0 if not specified.
wrapping_cost_tax
: Defaults to 0.0 if not specified.
notes
: Customer notes on the order.
billing_company
: Company name for billing address
billing_first_name
: Customer first name for billing address
billing_last_name
: Customer last name for billing address
billing_address
: First address line for billing address
billing_address2
: Additional address line for billing address
billing_city
: City name for billing address
billing_state
: State name for billing address
billing_country
: Country name for billing address
billing_postal_code
: Postal code for billing address
billing_phone_number
: Phone number.
billing_email
: Email address
recipients
: A nested associative array of recipient attributes. At least one recipient is required.
recipients > company
: Company name for shipping address
recipients > first_name
: Customer first name for shipping address
recipients > last_name
: Customer last name for shipping address
recipients > address
: Required. First address line for shipping address
recipients > address2
: Additional address line for shipping address
recipients > city
: City name for shipping address
recipients > state
: State name for shipping address
recipients > country
: Country name for shipping address
recipients > residential
: Whether or not address is residential or not. Value can be "true" or "false".
recipients > postal_code
: Required. Postal code for shipping address
recipients > postal_code_plus_4
: Postal code plus 4 for shipping address
recipients > phone_number
: Customer phone number
recipients > email
: Customer email address
recipients > base_cost
: Cost before tax for all line items sent to this recipient
recipients > cost_excluding_tax
: Cost before tax for all line items sent to this recipient
recipients > cost_including_tax
: Cost including tax for all line items sent to this recipient
recipients > cost_tax
: Cost of the tax for all line items sent to this recipient
recipients > base_handling_cost
: Handling cost before tax for all line items sent to this recipient
recipients > handling_cost_excluding_tax
: Handling cost before tax for all line items sent to this recipient
recipients > handling_cost_including_tax
: Handling cost including tax for all line items sent to this recipient
recipients > handling_cost_tax
: Handling cost of the tax for all line items sent to this recipient
recipients > shipping_zone_id
: ID of the shipping zone.
recipients > shipping_zone_name
: Name of the shipping zone.
recipients > shipping_method
: Method of shipment.
recipients > items_total
: Total number of items.
recipients > items_shipped
: Total number of items shipped.
recipients > line_items
: A nested associative array of line item attributes. At least one line item is required.
recipients > line_items > item_name
: Name of the item/product.
recipients > line_items > sku
: SKU of the item/product.
recipients > line_items > bin_picking_number
: Bin number where the item may be stored in a warehouse.
recipients > line_items > weight_in_ounces
: Weight of the line item in ounces.
recipients > line_items > quantity
: Quantity of the the items for the line item.
recipients > line_items > total_excluding_tax
: Total excluding tax for the line item.
recipients > line_items > unit_price
: Unit price of the item.
recipients > line_items > product_options
: Hash of product variations applicable to this line item. E.g. {"color":"red", "size":"XXL"}