OrdersUpdate Endpoint

Overview

It wouldn't be unusual to need to update an existing order.  This endpoint allows you to update any specific order in your store.

Requirements

The following pre-requisites will be necessary to accomplish the goals of this article:

  • General understanding of REST and API’s
  • Understanding of C# and/or JavaScript
  • Visual Studio 2012 or newer

Getting Started

You should already have a project open and ready to accept code to allow you to use this REST API endpoint.  You should also have one or more orders created so that you can successfully find one to update.

OrdersUpdate

This REST API endpoint allows you to update an order in your store. This requires that you also have an order to update, which would mean that you should also call the OrdersFind endpoint to get an existing order.

Example URL

This is what the REST endpoint will look like if you are calling it using JavaScript.  See our REST API URL documentation for more information.

http://example.com/DesktopModules/Hotcakes/API/rest/v1/orders/[BVIN]

BVIN is the order ID as described in the parameters below.

HTTP Method

POST

Parameters

Parameter Description
bvin This is the unique ID of the order that you wish to update
data You will need to pass an updated JSON version of the OrderDTO object in your post request

Returns

If successful, this endpoint will return a populated OrderDTO object in JSON format.  Otherwise, you should have one or more errors returned.  

Example Code

The following code will allow you to successfully call this endpoint, provided that you have enabled it.

Project References

  • Hotcakes.CommerceDTO

Import Namespaces

  • Hotcakes.CommerceDTO.v1
  • Hotcakes.CommerceDTO.v1.Client
  • Hotcakes.CommerceDTO.v1.Orders

 

string url = "http://example.com";
string key = "YOUR-API-KEY";

Api proxy = new Api(url, key);

// specify the order to look for
var orderId = "f8e72ad2-6f8b-4914-a09b-d46af5276286";

// call the API to find the order
var order = proxy.OrdersFind(orderId).Content;

// update one or many properties
order.Items.Add(new LineItemDTO
{
    ProductId = "b1ee12d3-950c-4bde-af8f-65eac37582f1",
    Quantity = 1
});

// call the API to update the order
ApiResponse<OrderDTO> response = proxy.OrdersUpdate(order);
// your domain name
var url = "http://example.com"; 
// the path where the API is
var apiPath = "/DesktopModules/Hotcakes/API/rest/v1/";  
// endpoint as shown in the documentation
var endPoint = "orders";  
// get this from the store admin
var apiKey = "YOUR-API-KEY";

$(document).ready(function() {

    // specify the order to look for
    var orderId = "f8e72ad2-6f8b-4914-a09b-d46af5276286";

    // call the API to find the order
    $.ajax({
        dataType: "json",
        url: url + apiPath + endPoint + "/" + orderId + "?key=" + apiKey,
        type: 'GET',
        success: function (data) {
            // update the order in another method
            UpdateOrder(data.Content);
        },
        error: function (jqXHR, textStatus) {
            // do something
        }
    });

});

function UpdateOrder(order) {

    // update one or many properties
    order.Items = [
        {
            "ProductId": "dfcae0ee-8bcf-4321-8b31-7883b5434285",
            "Quantity": 1
        },
        {
            "ProductId": "b1ee12d3-950c-4bde-af8f-65eac37582f1",
            "Quantity": 1
        }
    ];

    // update the dates to JS friendly dates
    order.LastUpdatedUtc = ParseDateForSave(order.LastUpdatedUtc);
    order.TimeOfOrderUtc = ParseDateForSave(order.TimeOfOrderUtc);
    order.BillingAddress.LastUpdatedUtc = ParseDateForSave(order.BillingAddress.LastUpdatedUtc);
    order.ShippingAddress.LastUpdatedUtc = ParseDateForSave(order.ShippingAddress.LastUpdatedUtc);

    // call the API to update the order
    $.ajax({
        dataType: "json",
        url: url + apiPath + endPoint + "/" + order.Bvin + "?key=" + apiKey,
        data: JSON.stringify(order),
        type: 'POST',
        success: function (data) {
            // do something
        },
        error: function (jqXHR, textStatus) {
            // do something else
        }
    });

}

function ParseDateForSave(dateValue) {
    // create a new date object in UTC format
    var newDate = new Date(parseInt(dateValue.substr(6)));

    // return the UTC version of the date
    return newDate.toISOString();
}
{
   "Errors":[

   ],
   "Content":{
      "Coupons":[

      ],
      "Items":[
         {
            "Id":25,
            "StoreId":1,
            "LastUpdatedUtc":"\/Date(1406675276273)\/",
            "BasePricePerItem":0.0000000000,
            "DiscountDetails":[

            ],
            "OrderBvin":"f8e72ad2-6f8b-4914-a09b-d46af5276286",
            "ProductId":"dfcae0ee-8bcf-4321-8b31-7883b5434285",
            "VariantId":"",
            "ProductName":"",
            "ProductSku":"",
            "ProductShortDescription":"",
            "Quantity":1,
            "QuantityReturned":0,
            "QuantityShipped":0,
            "ShippingPortion":0.0000000000,
            "StatusCode":"",
            "StatusName":"",
            "TaxRate":0.0000000000,
            "TaxPortion":0.0000000000,
            "SelectionData":[

            ],
            "IsNonShipping":false,
            "TaxSchedule":0,
            "ProductShippingWeight":0.0000,
            "ProductShippingLength":0.0000,
            "ProductShippingWidth":0.0000,
            "ProductShippingHeight":0.0000,
            "CustomProperties":[
               {
                  "DeveloperId":"hcc",
                  "Key":"ismarkedforfreeshipping",
                  "Value":"False"
               },
               {
                  "DeveloperId":"hcc",
                  "Key":"istaxexempt",
                  "Value":"False"
               },
               {
                  "DeveloperId":"hcc",
                  "Key":"freeshippingmethodsids",
                  "Value":""
               }
            ],
            "ShipFromMode":0,
            "ShipFromNotificationId":"",
            "ShipFromAddress":{
               "Bvin":null,
               "LastUpdatedUtc":"\/Date(1406671991288)\/",
               "StoreId":0,
               "NickName":"",
               "FirstName":"",
               "MiddleInitial":"",
               "LastName":"",
               "Company":"",
               "Line1":"",
               "Line2":"",
               "Line3":"",
               "City":"",
               "RegionName":"",
               "RegionBvin":"",
               "PostalCode":"",
               "CountryName":"United States",
               "CountryBvin":"bf7389a2-9b21-4d33-b276-23c9c18ea0c0",
               "Phone":"",
               "Fax":"",
               "WebSiteUrl":"",
               "UserBvin":"",
               "AddressType":0
            },
            "ShipSeparately":false,
            "ExtraShipCharge":0.0000
         },
         {
            "Id":27,
            "StoreId":1,
            "LastUpdatedUtc":"\/Date(1406675276274)\/",
            "BasePricePerItem":0.0000000000,
            "DiscountDetails":[

            ],
            "OrderBvin":"f8e72ad2-6f8b-4914-a09b-d46af5276286",
            "ProductId":"b1ee12d3-950c-4bde-af8f-65eac37582f1",
            "VariantId":"",
            "ProductName":"",
            "ProductSku":"",
            "ProductShortDescription":"",
            "Quantity":1,
            "QuantityReturned":0,
            "QuantityShipped":0,
            "ShippingPortion":0.0000000000,
            "StatusCode":"",
            "StatusName":"",
            "TaxRate":0.0000000000,
            "TaxPortion":0.0000000000,
            "SelectionData":[

            ],
            "IsNonShipping":false,
            "TaxSchedule":0,
            "ProductShippingWeight":0.0000,
            "ProductShippingLength":0.0000,
            "ProductShippingWidth":0.0000,
            "ProductShippingHeight":0.0000,
            "CustomProperties":[
               {
                  "DeveloperId":"hcc",
                  "Key":"ismarkedforfreeshipping",
                  "Value":"False"
               },
               {
                  "DeveloperId":"hcc",
                  "Key":"istaxexempt",
                  "Value":"False"
               },
               {
                  "DeveloperId":"hcc",
                  "Key":"freeshippingmethodsids",
                  "Value":""
               }
            ],
            "ShipFromMode":0,
            "ShipFromNotificationId":"",
            "ShipFromAddress":{
               "Bvin":null,
               "LastUpdatedUtc":"\/Date(1406673837307)\/",
               "StoreId":0,
               "NickName":"",
               "FirstName":"",
               "MiddleInitial":"",
               "LastName":"",
               "Company":"",
               "Line1":"",
               "Line2":"",
               "Line3":"",
               "City":"",
               "RegionName":"",
               "RegionBvin":"",
               "PostalCode":"",
               "CountryName":"United States",
               "CountryBvin":"bf7389a2-9b21-4d33-b276-23c9c18ea0c0",
               "Phone":"",
               "Fax":"",
               "WebSiteUrl":"",
               "UserBvin":"",
               "AddressType":0
            },
            "ShipSeparately":false,
            "ExtraShipCharge":0.0000
         },
         {
            "Id":30,
            "StoreId":1,
            "LastUpdatedUtc":"\/Date(1406675276276)\/",
            "BasePricePerItem":0,
            "DiscountDetails":[

            ],
            "OrderBvin":"f8e72ad2-6f8b-4914-a09b-d46af5276286",
            "ProductId":"b1ee12d3-950c-4bde-af8f-65eac37582f1",
            "VariantId":"",
            "ProductName":"",
            "ProductSku":"",
            "ProductShortDescription":"",
            "Quantity":1,
            "QuantityReturned":0,
            "QuantityShipped":0,
            "ShippingPortion":0,
            "StatusCode":"",
            "StatusName":"",
            "TaxRate":0,
            "TaxPortion":0,
            "SelectionData":[

            ],
            "IsNonShipping":false,
            "TaxSchedule":0,
            "ProductShippingWeight":0,
            "ProductShippingLength":0,
            "ProductShippingWidth":0,
            "ProductShippingHeight":0,
            "CustomProperties":[
               {
                  "DeveloperId":"hcc",
                  "Key":"ismarkedforfreeshipping",
                  "Value":"False"
               },
               {
                  "DeveloperId":"hcc",
                  "Key":"istaxexempt",
                  "Value":"False"
               },
               {
                  "DeveloperId":"hcc",
                  "Key":"freeshippingmethodsids",
                  "Value":""
               }
            ],
            "ShipFromMode":0,
            "ShipFromNotificationId":"",
            "ShipFromAddress":{
               "Bvin":null,
               "LastUpdatedUtc":"\/Date(1406675275852)\/",
               "StoreId":0,
               "NickName":"",
               "FirstName":"",
               "MiddleInitial":"",
               "LastName":"",
               "Company":"",
               "Line1":"",
               "Line2":"",
               "Line3":"",
               "City":"",
               "RegionName":"",
               "RegionBvin":"",
               "PostalCode":"",
               "CountryName":"United States",
               "CountryBvin":"bf7389a2-9b21-4d33-b276-23c9c18ea0c0",
               "Phone":"",
               "Fax":"",
               "WebSiteUrl":"",
               "UserBvin":"",
               "AddressType":0
            },
            "ShipSeparately":false,
            "ExtraShipCharge":0
         }
      ],
      "Notes":[

      ],
      "Packages":[

      ],
      "Id":10,
      "Bvin":"f8e72ad2-6f8b-4914-a09b-d46af5276286",
      "StoreId":1,
      "LastUpdatedUtc":"\/Date(1406675276270)\/",
      "TimeOfOrderUtc":"\/Date(1406722391280)\/",
      "OrderNumber":"",
      "ThirdPartyOrderId":"",
      "UserEmail":"info@hotcakescommerce.com",
      "UserID":"1",
      "CustomProperties":[
         {
            "DeveloperId":"hcc",
            "Key":"ApplyVATRules",
            "Value":"False"
         }
      ],
      "PaymentStatus":0,
      "ShippingStatus":0,
      "IsPlaced":false,
      "StatusCode":"",
      "StatusName":"",
      "BillingAddress":{
         "Bvin":null,
         "LastUpdatedUtc":"\/Date(1406671991282)\/",
         "StoreId":0,
         "NickName":"",
         "FirstName":"John",
         "MiddleInitial":"",
         "LastName":"Dough",
         "Company":"",
         "Line1":"319 N. Clematis Street",
         "Line2":"Suite 500",
         "Line3":"",
         "City":"West Palm Beach",
         "RegionName":"",
         "RegionBvin":"7EBE4F07-A844-47B8-BDA8-863DDDF5C778",
         "PostalCode":"33401",
         "CountryName":"",
         "CountryBvin":"BF7389A2-9B21-4D33-B276-23C9C18EA0C0",
         "Phone":"561-228-5319",
         "Fax":"",
         "WebSiteUrl":"",
         "UserBvin":"",
         "AddressType":1
      },
      "ShippingAddress":{
         "Bvin":null,
         "LastUpdatedUtc":"\/Date(1406671991282)\/",
         "StoreId":0,
         "NickName":"",
         "FirstName":"John",
         "MiddleInitial":"",
         "LastName":"Dough",
         "Company":"",
         "Line1":"319 N. Clematis Street",
         "Line2":"Suite 500",
         "Line3":"",
         "City":"West Palm Beach",
         "RegionName":"",
         "RegionBvin":"7EBE4F07-A844-47B8-BDA8-863DDDF5C778",
         "PostalCode":"33401",
         "CountryName":"",
         "CountryBvin":"BF7389A2-9B21-4D33-B276-23C9C18EA0C0",
         "Phone":"561-228-5319",
         "Fax":"",
         "WebSiteUrl":"",
         "UserBvin":"",
         "AddressType":1
      },
      "AffiliateID":null,
      "FraudScore":0.00,
      "Instructions":"",
      "ShippingMethodId":"",
      "ShippingMethodDisplayName":"",
      "ShippingProviderId":"",
      "ShippingProviderServiceCode":"",
      "TotalTax":0.0000000000,
      "ItemsTax":0,
      "ShippingTax":0.0000000000,
      "ShippingTaxRate":0,
      "TotalShippingBeforeDiscounts":0.0000000000,
      "TotalHandling":0.0000000000,
      "OrderDiscountDetails":[

      ],
      "ShippingDiscountDetails":[

      ]
   }
}
Have more questions? Submit a request

Need More Help?

Do you need more assistance with this article? Please review your support options.