question

wes avatar image
wes asked Jacob Abrams answered

Using the REST API to associate variants to their attributes and options.

Hello,

I am having a problem figuring out how to use your API to match variants with their associated options/attributes.

For example, lets say I have an item with variants called Shirt with an attribute Size and option Small and another attribute Color with option Red and Blue. This would create two variants called 'Shirt Small Red' and 'Shirt Small Blue'.

Is there somewhere in the API that tells you what attributes and options are associated with a specific variant? When using something like the item_groups endpoint you can get a response like.

{
  "id": "",
  "name": "shirt",
  "items": {
    "elements": [
      {
        "id": "123",
        "hidden": false,
        "itemGroup": {
          "id": ""
        },
        "name": "shirt red small",
        "alternateName": "",
        "code": "",
        "sku": "",
        "price": 1,
        "priceType": "FIXED",
        "defaultTaxRates": true,
        "unitName": "",
        "isRevenue": true,
        "modifiedTime": 1452694038000
      },
      {
        "id": "",
        "hidden": false,
        "itemGroup": {
          "id": ""
        },
        "name": "shirt blue small",
        "alternateName": "",
        "code": "",
        "sku": "",
        "price": 1,
        "priceType": "FIXED",
        "defaultTaxRates": true,
        "unitName": "",
        "isRevenue": true,
        "modifiedTime": 1452693218000
      }
    ]
  },
  "attributes": {
    "elements": [
      {
        "id": "",
        "name": "color",
        "itemGroup": {
          "id": ""
        }
      },
      {
        "id": "",
        "name": "size",
        "itemGroup": {
          "id": ""
        }
      }
    ]
  }
}

Which gives some helpful information but from what I can see this only gives you the possible option and attributes for an item group and not which ones belong to which variant. Is there a way to figure out that the name 'shirt red small' is made up of an attribute 'Color' with option 'Red' and an attribute 'Size' with option 'Small'. I guess what I am looking for is something like this.

    {
  "id": "",
  "name": "shirt",
  "items": {
    "elements": [
      {
        "id": "123",
        "hidden": false,
        "itemGroup": {
          "id": ""
        },
        "name": "shirt red small",
        "alternateName": "",
        "code": "",
        "sku": "",
        "price": 1,
        "priceType": "FIXED",
        "defaultTaxRates": true,
        "unitName": "",
        "isRevenue": true,
        "modifiedTime": 1452694038000,
        "options": [
          {
            "name": 'Color',
            "value": 'Red'
          },
          {
            "name": 'Size'
            "value": 'Small'
          }
        ]
      }
    ]
  }
}

Thanks for any help!

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jacob Abrams avatar image
Jacob Abrams answered

Clover has not yet implemented the ability to determine which options are associated with a particular item in a single go. It definitely seems like a glaring omission. Take a look at this ticket for some more information and a possible workaround:

http://devask.clover.com/question/749...

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community