Options are the variations that each product SKU might have, for example color or size. Different display controls can be used to display options: a dropdown list, check boxes, or a color picker. The different values that an option can have are called option choices. For example, the option color might use a dropdown list to display the option choices of black, green, and purple. A product can have 0-n options, and an option can have 1-n option choices.

If you want to add/change/delete the options for a product, use the PUT endpoint on the Products API. For example, if you wanted to add the color option of yellow to a product, you’d use PUT and replace skus with all the available options, including yellow. You can then use the PATCH endpoint from the Product Option API to change the order.

Fields

The following table shows all fields that exist for this API, those that are returned when you retrieve a list, and those that are changeable using PATCH. All fields are returned when you retrieve a single item.

Name Description Type List Changeable
user_id The unique ID of the authenticated user string X
site_id ID of a Weebly site, unique to the currently authenticated user​ string X
product_id Unique ID (to this store) for the product. string X
product_option_id ​Unique ID (to this product) for this option. integer X
name The name of this option, for example Color or Size. string X
renderer The UI control used to display the choices for this option.
Valid values are:
  • dropdown
  • color
  • radio
string X
choice_order An array of values for this option, in the order that they should be displayed. Colors need to include a hex value.
For example, if the option name is Color, the choice order might be:
["black<#000>", "purple<#b073da>", "green<#508d24>"]
You can also add just a hex value first to have a default color display.
For example:
["<#000>", "black<#000>", "purple<#b073da>", "green<#508d24>"]
array X X
required Whether or not an option must be selected to be purchased.
Valid values are:
  • true
  • false
boolean X
max_length Whether or not an option with a renderer of text has a maximum character length.
Valid values are:
  • true
  • false
boolean X
created_date Date the option was created. Unix GMT Timestamp
updated_date Date the option was last updated. Unix GMT Timestamp X

GET
Retrieve a List of Options for a Product

GET /v1/user/sites/{SITE_ID}/store/products/{PRODUCT_ID}/options

Returns all options for the given product. Only list fields are returned.


scope: read:store-catalog

Example CURL request returning all options:

curl --request GET \
--url https://api.weebly.com/v1/user/sites/987654321/store/products/123/options \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"

Example response:

[
    {
        "user_id": "123456",
        "site_id": "987654321",
        "product_id": "2",
        "product_option_id": 1,
        "name": "Color",
        "renderer": "color",
        "choice_order": [
            "<#000>",
            "Black<#000>",
            "Green<#508d24>",
            "purple<#b073da>"
        ],
        "required": true,
        "max_length": false
    },
    {
        "user_id": "123456",
        "site_id": "987654321",
        "product_id": "2",
        "product_option_id": 2,
        "name": "Size",
        "renderer": "radio",
        "choice_order": [
            "Small",
            "Medium",
            "Large"
        ],
        "required": true,
        "max_length": false
    }
]

GET
Retrieve the Number of Options for a Product

GET /v1/user/sites/{SITE_ID}/store/products/{PRODUCT_ID}/options/count

Returns the number of options for the product.


scope: read:store-catalog

Example CURL request:

curl --request GET \
--url https://api.weebly.com/v1/user/sites/987654321/store/products/123/options/count \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"

Example response:

{
    "count": 2
}

GET
Retrieve Details for a Product Option

GET /v1/user/sites/{SITE_ID}/store/products/{PRODUCT_ID}/options/{PRODUCT_OPTION_ID}

Returns all fields for the given product option.


scope: read:store-catalog

Example CURL request:

curl --request GET \
--url https://api.weebly.com/v1/user/sites/987654321/store/products/123/options/2 \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"

Example response:

See Fields table. All fields for the option are returned.

{
    "user_id": "123456",
    "site_id": "987654321",
    "product_id": "123",
    "product_option_id": 2,
    "name": "Size",
    "renderer": "radio",
    "choice_order": [
        "Small",
        "Medium",
        "Large"
    ],
    "required": true,
    "max_length": false
}

PATCH
Update a Product Option

PATCH /v1/user/sites/{SITE_ID}/store/products/{PRODUCT_ID}/options/{PRODUCT_OPTION_ID}

Updates the given product option.


scope: write:store-catalog

These fields can be updated:

Name Description Type
choice_order An array of values for this option, in the order that they should be displayed. Colors need to include a hex value.
For example, if the option name is Color, the choice order might be:
["black<#000>", "purple<#b073da>", "green<#508d24>"]
You can also add just a hex value first to have a default color display.
For example:
["<#000>", "black<#000>", "purple<#b073da>", "green<#508d24>"]
array

Example CURL request:

curl --request PATCH \
--url https://api.weebly.com/v1/user/sites/987654321/store/products/123/options/2 \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"
--data '{
            "choice_order": ["Large","Medium","Small"]
        }'

Example response:

See Fields table. All fields for the product option are returned.</p>

{
    "user_id": "123456",
    "site_id": "987654321",
    "product_id": "123",
    "product_option_id": 2,
    "name": "Size",
    "renderer": "radio",
    "choice_order": [
        "Large",
        "Medium",
        "Small"
    ],
    "required": true,
    "max_length": false
}

Help make these docs better!









Tags: