Jump to content

Cannot update existing variants via API


KCFBricks

Recommended Posts

I've written a script to sync items into Loyverse from another source, and as part of this I need to occasionaly update prices for the items. My current script creates items and its variants in one API call, specifying the existing IDs if they already exist. However, when calling the items API with variants, the prices are not updated, and when calling the variants API explicitly with the variant ID specified, I get back an INVALID_VALUE error with the message "Could not add variant to item with id <id> because it has no options." This doesn't make sense to me as the documentation - https://developer.loyverse.com/docs/#tag/Variants/paths/~1variants/post - says that specifying a variant ID when making the call should update the variant rather than creating a new one, so it shouldn't be trying to add another variant to the same item. Can this be looked into?

Link to comment
Share on other sites

Hello @KCFBricks

Thank you for your comment.

The error message "Could not add variant to item with id <id> because it has no options." means that the variant you were trying to update didn't have "Option name" and "Option value".

Could you put the item detail that you want to update and request payload?

Link to comment
Share on other sites

Hi there, here's a snippet of the item I'm trying to update, directly from the API - note that even though there's no set options, there's still a single variant listed.

{
  "id": "<GUID from Loyverse>",
...
  "option1_name": null,
  "option2_name": null,
  "option3_name": null,
...
  "variants": [
    {
      "variant_id": "<GUID from Loyverse>",
      "item_id": "<item GUID from Loyverse>",
      "option1_value": null,
      "option2_value": null,
      "option3_value": null,

...
      "default_pricing_type": "FIXED",
      "default_price": 28,
...
    }
  ]
}

 

I want to update the default price, so I make a call to the /variants endpoint with this payload:

{
  "default_pricing_type": "FIXED",
  "default_price": <the new price>,
  "variant_id": "<variant GUID from the above call>",
  "item_id": "<item GUID from the above call>"
}

I then get back the error message from the original post.

I've worked around this issue for now by just removing the item and recreating it, but I'd like to actually update it - if this isn't the correct way, how would I go about doing it?

Link to comment
Share on other sites

Loyverse Point of Sale

 

 

 

 

×
×
  • Create New...