ListOrderItems

SmithCart > Integration > REST Endpoints
Usage
Lists an order purchased items
Basic URI
/orders/{id}/items.json?top={top}&skip={skip}&orderby={orderby}
Parameters
int oid                The order ID
int top               The maximum number of rows to return
long skip            The start row index
string orderby    A sort expression
HTTP Example
https://domain.com/DesktopModules/Smith.BuyNow/Services/v1/Checkout.svc/orders/9/items.json?top=20&skip=5&orderby=-order_date
AUTH
Bearer JWT
 
C# Code
 
JavaScript Code
<script>
   (function ($) {
       var CLIENT_ID = "4SnPA6lqpY76ODEr",
           SERVICE_URI = "https://domain.com/DesktopModules/Smith.BuyNow/Services/v1/",
           ORDER_ID = "9",
           DATA_LIMIT = "20",
           SKIP = "10",
           ORDER_BY = "-order_date";

       function listOrderItems (endPoint, clientID, oid, top, skip, orderBy) {
           var jwt = sessionStorage.getItem("jwt");
           if (!jwt) {
               var uri = endPoint + "Authorize.ashx?"
                   + "response_type=token"
                   + "&client_id=" + clientID
                   + "&redirect_uri=" + encodeURIComponent(window.location)
                   + "&scope=" + encodeURIComponent("orders create edit delete");
               window.location = uri;
               return;
           }

           $.ajax({
               type: "GET",
               url: endPoint + "/Checkout.svc/orders/" + oid + "/items.json?top="
                    + top + "&skip=" + skip + "&orderby=" + orderBy,
               headers: { "Authorization": "Bearer " + jwt },
               contentType: "application/json; charset=utf-8",
               dataType: "json"
           }).fail(function (jqXHR, textStatus) {
               console.log("SmithCart API: " + textStatus);
           });
       }

       $(function () {
           var params = {},
               queryString = location.hash.substring(1),
               regex = /([^&=]+)=([^&]*)/g,
               m;

           while (m = regex.exec(queryString)) {
               params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
           }
           if (params["access_token"]) {
               sessionStorage.setItem("jwt", params["access_token"]);
           }

           listOrderItems (SERVICE_URI, CLIENT_ID, ORDER_ID, DATA_LIMIT, SKIP, ORDER_BY);
       });
   })(jQuery);
</script>
 
 
 
Response
[
    {
        "id": 12,
        "order_id": 9,
        "sku": "SCTest9",
        "title": "Smith Test Product #9",
        "unit_price": 9.00,
        "sale_price": null,
        "tax_rate": 0,
        "qty": 1,
        "units": null,
        "total": 9.00,
        "subtotal": 9.00,
        "tax_total": 0.00,
        "fee_total": 0.00,
        "shipping_total": 0.00,
        "discount_total": 0.00,
        "status": null,
        "portal_id": 0
    },
    {
        "id": 11,
        "order_id": 9,
        "sku": "SCTest7",
        "title": "Smith Test Product #7",
        "unit_price": 7.00,
        "sale_price": null,
        "tax_rate": 0,
        "qty": 2,
        "units": null,
        "total": 14.00,
        "subtotal": 14.00,
        "tax_total": 0.00,
        "fee_total": 0.00,
        "shipping_total": 0.00,
        "discount_total": 0.00,
        "status": null,
        "portal_id": 0
    }
]