Adding Line Items
Viewing My Orders
If you don't remember your Order ID, fear not - buyer users can view their orders using the My Orders
resource. This will provide a list of orders that have the currently authenticated user as the FromUser
.
1GET https://sandboxapi.ordercloud.io/v1/me/orders HTTP/1.12Authorization: Bearer INSERT_ACCESS_TOKEN_HERE3Content-Type: application/json; charset=UTF-8;
Creating a Line Item
Now that we know how to browse products available to our buyer user and the direction and ID of the order we are working with - we can populate our order with a line item.
1POST https://sandboxapi.ordercloud.io/v1/orders/Outgoing/INSERT_ORDER_ID_HERE/lineitems HTTP/1.12Authorization: Bearer INSERT_ACCESS_TOKEN_HERE3Content-Type: application/json; charset=UTF-8;45{6 "ProductID": "SHIRT",7 "Quantity": 28}
Your response should look like this:
1{2 "ID": "wvBDPU-WM0CaHpDaIplJcA",3 "ProductID": "SHIRT",4 "Quantity": 2,5 "DateAdded": "2021-03-01T22:00:05.437+00:00",6 "QuantityShipped": 0,7 "UnitPrice": 10,8 "PromotionDiscount": 0,9 "LineTotal": 20,10 "LineSubtotal": 20,11 "CostCenter": null,12 "DateNeeded": null,13 "ShippingAccount": null,14 "ShippingAddressID": null,15 "ShipFromAddressID": null,16 "Product": {17 "ID": "SHIRT",18 "Name": "Cotton T-Shirt",19 "Description": "A plain white, cotton shirt for everyday use.",20 "QuantityMultiplier": 1,21 "ShipWeight": null,22 "ShipHeight": null,23 "ShipWidth": null,24 "ShipLength": null,25 "xp": null26 },27 "Variant": null,28 "ShippingAddress": null,29 "ShipFromAddress": null,30 "SupplierID": null,31 "Specs": [],32 "xp": null33}
LineItem Response Model
Like the buyer product model, you can see that line item has a sub-object for the Product
attached to it. Though, this is not a buyer product with a full price schedule. Pricing information appears on the root of the line item model.
Note that since we added a Quantity
of two, the API automatically will calculate UnitPrice
, LineTotal
, and LineSubtotals
.
We rely on these line item properties to show the cost in a shopping cart because the price schedule is only 1 piece to calculating actual purchase price.
If there was a product spec for "shirt size" that incurred a price markup of say, $2.00 - the new unit price would be $12.00.
If there were any applicable line item promotions, the PromotionDiscount
and LineSubtotal
might be affected. Perhaps a BOGO offer is applied to our product so the second unit should be free. Which would bring our sub total back down to $10.00.
Retrieve the Order
Now that we have added a LineItem, let's retrieve our order again and see how it has changed. Use the example at the top of this guide. Your response should now look something like this:
1{2 "Meta": {3 "Page": 1,4 "PageSize": 20,5 "TotalCount": 1,6 "TotalPages": 1,7 "ItemRange": [8 1,9 110 ]11 },12 "Items": [13 {14 "ID": "PKTiEFNEiEi9mEmC9cZCrw",15 "FromUser": {16 "ID": "BUYER_USER",17 "Username": "buyer01",18 "Password": null,19 "FirstName": "Buyer",20 "LastName": "User",21 "Email": "buyer@email.com",22 "Phone": null,23 "TermsAccepted": null,24 "Active": true,25 "xp": null,26 "AvailableRoles": null,27 "Locale": null,28 "DateCreated": "2021-02-08T23:09:14.82+00:00",29 "PasswordLastSetDate": "2021-02-08T23:10:00.56+00:00"30 },31 "FromCompanyID": "BUYER_ORGANIZATION",32 "ToCompanyID": "bClEeDV0f9GjjkGD",33 "FromUserID": "BUYER_USER",34 "BillingAddressID": null,35 "BillingAddress": null,36 "ShippingAddressID": null,37 "Comments": null,38 "LineItemCount": 1,39 "Status": "Unsubmitted",40 "DateCreated": "2021-02-23T20:39:03.173+00:00",41 "DateSubmitted": null,42 "DateApproved": null,43 "DateDeclined": null,44 "DateCanceled": null,45 "DateCompleted": null,46 "Subtotal": 20,47 "ShippingCost": 0,48 "TaxCost": 0,49 "PromotionDiscount": 0,50 "Currency": null,51 "Total": 20,52 "IsSubmitted": false,53 "LineItems": null,54 "xp": null55 }56 ]57}
Notice that the orders LineItemCount
, Subtotal
and Total
have changed.
Still have questions?
Ask in our Community Channel