Solved

Back in Stock / Custom API call successful but not showing

  • 4 May 2022
  • 1 reply
  • 172 views

Badge
  • New Member
  • 0 replies

Hello,

We are using a Shopify headless build and are developing a custom Back in Stock feature on the frontend and have had success setting it for out of stock products based on the following guide:

https://developers.klaviyo.com/en/docs/how-to-set-up-custom-back-in-stock

 

We have no problems making a call to a Product that contains both a Product ID and a Variant (for instance: size or colour) — if the product is published in the catalog, it creates that entry under Profile > Email address as well as shows in the activity feed.

But for simple products without variants (flat with no options), we are struggling to figure out what to include — sending just the product ID but no Variant ends up with an error stating that the “variant” property is required. Most guides seem to just use the Product ID for the Variant, but that does not seem to register despite a successful post request being made. We ensured the said item in question is published but cannot find it anywhere despite a successful 200 response.

Also there seem to be a few different URL endpoints being used: `https://a.klaviyo.com/api/v1/catalog/subscribe` and `https://a.klaviyo.com/onsite/components/back-in-stock/subscribe` — does it matter which one to use?

 

Any help at this stage would be greatly appreciated, thanks in advance!

icon

Best answer by David To 4 May 2022, 19:52

View original

1 reply

Userlevel 7
Badge +53

Hello @art,

Welcome to the Klaviyo Community!

I think it would really help the rest of the community if you could share an example of the call you’re making!

In my experience, for products that do not have variants, replacing the variant ID parameter with the product’s ID should be sufficient. Klaviyo monitors inventory levels on a variant level which means having a variant ID parameter is required as part of your call. Any additional fields would just be extras as part of your custom event. 

As detailed in the Subscribing Customers to Back in Stock Alerts subsection of the Enable Back in Stock for Custom Catalog Feeds Developer Portal which goes over enabling back in stock for custom integrations:

The JSON object requires all of the following arguments:

  • a - your public API key
  • email - the email address of the person subscribing to alerts for this item
  • variant - the ID of the item (must correspond with $id in the field mapping step)
  • platform - this should be set to “api”

If you had instead replaced the variant ID parameter with a product id, it’s not surprising you would receive this error. 

I hope this helps!

David

Reply