ProductOptionsFindAllByProductId Endpoint

Overview

Sometimes you just need to find some product options to do something unique with them.  This endpoint allows you to find all options matching a specific product in your store using the ID or BVIN of the product.

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 products and options created so that you can successfully find them.

ProductOptionsFindAllByProductId

This REST API endpoint allows you to find the options for a product in your store using the respective ID of the product.

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/productoptions?key=[YOURKEY]&productbvin=[BVIN]

BVIN is the unique ID of the product as described in the parameters below.

HTTP Method

GET

Parameters

Parameter Description
productbvin This is the unique ID of the product that you wish to find options for.

Returns

If successful, this endpoint will return a populated list of OptionDTO 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.Catalog
  • Hotcakes.CommerceDTO.v1.Client

 

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

Api proxy = new Api(url, key);

// specify the product ID to find options for
var productId = "06f2347e-ee44-4c54-a530-61f6848f2bea";

// call the API to find all product options
ApiResponse<List<OptionDTO>> response = proxy.ProductOptionsFindAllByProductId(productId);
// 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 = "productoptions";  
// get this from the store admin
var apiKey = "YOUR-API-KEY";

$(document).ready(function() {

    // specify the product ID to find options for
    var productId = "06f2347e-ee44-4c54-a530-61f6848f2bea";

    // call the API to find all product options
    $.ajax({
        dataType: "json",
        url: url + apiPath + endPoint + "?key=" + apiKey + "&productbvin=" + productId,
        type: 'GET',
        success: function (data) {
            // do something
        },
        error: function (jqXHR, textStatus) {
           // do something else
        }
    });

});
{
   "Errors":[

   ],
   "Content":[
      {
         "Bvin":"875f5566-b49c-483c-8e44-d3ad718d46a6",
         "StoreId":1,
         "OptionType":100,
         "Name":"Size",
         "NameIsHidden":false,
         "IsVariant":false,
         "IsShared":false,
         "Settings":[

         ],
         "TextSettings":[

         ],
         "Items":[
            {
               "Bvin":"87007e7e-bd5b-4b4b-8920-6ccfa92d4209",
               "StoreId":1,
               "OptionBvin":"875f5566-b49c-483c-8e44-d3ad718d46a6",
               "Name":"M 700C",
               "PriceAdjustment":0,
               "WeightAdjustment":0,
               "IsLabel":false,
               "SortOrder":1,
               "IsDefault":false
            },
            {
               "Bvin":"492b6d68-ca35-43c1-ba8f-90a21c4e09d9",
               "StoreId":1,
               "OptionBvin":"875f5566-b49c-483c-8e44-d3ad718d46a6",
               "Name":"M 750C",
               "PriceAdjustment":0,
               "WeightAdjustment":0,
               "IsLabel":false,
               "SortOrder":2,
               "IsDefault":false
            }
         ]
      },
      {
         "Bvin":"0adfcac3-ca43-49a3-ad81-44b2e7d9b9b6",
         "StoreId":1,
         "OptionType":100,
         "Name":"Color",
         "NameIsHidden":false,
         "IsVariant":false,
         "IsShared":false,
         "Settings":[

         ],
         "TextSettings":[

         ],
         "Items":[
            {
               "Bvin":"7175c832-4505-4c92-b0af-1b8838f2b9d8",
               "StoreId":1,
               "OptionBvin":"0adfcac3-ca43-49a3-ad81-44b2e7d9b9b6",
               "Name":"BLACK",
               "PriceAdjustment":0,
               "WeightAdjustment":0,
               "IsLabel":false,
               "SortOrder":1,
               "IsDefault":false
            },
            {
               "Bvin":"180ad8d6-c140-4b48-bb47-148916c0911b",
               "StoreId":1,
               "OptionBvin":"0adfcac3-ca43-49a3-ad81-44b2e7d9b9b6",
               "Name":"WHITE",
               "PriceAdjustment":0,
               "WeightAdjustment":0,
               "IsLabel":false,
               "SortOrder":2,
               "IsDefault":false
            }
         ]
      }
   ]
}
Have more questions? Submit a request

Need More Help?

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