question

Sean avatar image
Sean asked sam Deactivated commented

Geting variant items

Hi, I'm having trouble on getting variant items from Clover Web API. That item with variants was created by a Clover Sandbox Android Device using an emulator. After creation, I can see that each item variants are listed as a single product in the web dashboard. Their relation however, cannot be seen. Other than their first name are similar, I can't see anything that grouped them together. Thus comes my problem, how do I get those items from the web API as a variant product ?

This is the case: I created a variant item in Clover Sandbox Device. Checked if it's actually uploaded to Clover, by looking at the web dashboard. Now on my web app, there's a button to import all products from Clover. On click, it will send item requests to Clover with offset and limit as additional arguments. From that request, I have already received item objects. Sadly, I can't identify which of those item objects are actually a variant items and which is related to the other.

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

sam avatar image
sam Deactivated answered sam Deactivated commented

Hi!

You should be able to identify Items of a variant by their 'itemGroup.id'. This property is only available when the item is part of a variation group.

You can specify the variation you want by filtering by itemGroup.id={groupid}. https://apisandbox.dev.clover.com/v3/...

You should be able to test it out using our api reference: https://sandbox.dev.clover.com/api_do...

Please let me know if this helps answer your question.

Best,

Sam

6 comments
10 |2000

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

Sean avatar image Sean commented ·

Hi, Sam.

Thanks for the answer, but sorry, it doesn't fully answer my question.

I've been meaning to say that I'm trying to get all of my current inventory ( some are normal product while some are variants ). I also use this as GET url ( /v3/merchants/{mId}/items ) in reference from your link. That will give me all of my items.

Problem is, from all of those item objects I received, how do I differentiate which is a variant product, and which is not?

0 Likes 0 ·
Sean avatar image Sean commented ·

After some testing of these two I'm able to get my variable items:

Here's what I use ( please correct me if I'm wrong ) :

  • GET /v3/merchants/{mId}/item_groups
  • GET /v3/merchants/{mId}/items?filter=itemGroup.id={id}

First one will returns all my variable items and each of its id, thus providing itemGroup.id filter for my second query. Second query returns all variable items associated with that id.

Problem is, items returned by the second query doesn't gives me information of what attributes attached to it, other than it's name. example: Standard Shirt White XL.

0 Likes 0 ·
sam avatar image sam commented ·

You should be getting more than just the name.

{
      "id": "xxxx",
      "hidden": false,
      "itemGroup": {
        "id": "807GYENKD7KVG"
      },
      "name": "Large Shirt",
      "alternateName": "",
      "code": "4646",
      "sku": "",
      "price": 100,
      "priceType": "FIXED",
      "defaultTaxRates": true,
      "unitName": "",
      "isRevenue": true,
      "modifiedTime": 1476298484000
    }

You can also return more attributes why using 'expand' params

0 Likes 0 ·
Sean avatar image Sean commented ·

Yes, I got those attributes. And I'm using that itemGroup id to query for it's group info.

A question though, if using /v3/merchants/{mId}/items got me all my current items, how do I filter out all variant items? Is there a query for that? Normally if I use that query, I would get these items:

  • Bandana
  • Guitar
  • Shirt White XL
  • etc

Shirt White XL is one of variant items. How do I query to Clover API to get:

  • Bandana
  • Guitar
  • etc

I just want to query all my items, without getting variant items.

0 Likes 0 ·
sam avatar image sam commented ·

There's no way to request for just the items without itemGroup.id, but you can filter the response for items without the itemGroup key/value pair.

eg. (javascript)

response.elements.filter((el) => { return el.itemGroup === undefined  })
0 Likes 0 ·
Show more comments

Welcome to the
Clover Developer Community