Solved

I'm setting up a headless shopify store and trying to get back in stock notifications working, but I'm having some trouble

  • 19 April 2022
  • 3 replies
  • 373 views

Badge +1

My fetch request looks like this

fetch(`https://a.klaviyo.com/api/v1/catalog/subscribe`, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
a: process.env.NEXT_PUBLIC_KLAVIYO_KEY,
email: email,
variant: properties.variantId,
platform: 'shopify'
})
})

but the issue is that my shopify variant Ids are alphanumeric and this endpoint is requiring the integer ID that comes from my klaviyo catalog, and I’m a bit stuck on how to get this working properly.

 

Any info would be great, thanks!

icon

Best answer by Taylor Tarpley 19 April 2022, 16:21

View original

3 replies

Userlevel 7
Badge +60

Hi there @logansparlin

 

Welcome to the Community! Thanks for sharing your question with us! 

 

Unfortunately, the headless Shopify theme is not listed as a supported theme in Shopify for back in stock and the Klaviyo team therefore can’t help you troubleshoot this issue. However, I would reach out to one of our awesome Klaviyo partners who would love to help get this set up for you! 

 

Thanks for participating in the Community!

-Taylor 

Badge +1

Hi Taylor, thanks for the response! I’ll reach out to one of the Klaviyo partners and see what I can figure out. Happy to be a part of the community!

Badge +1

Solved my own problem, turns out I just had to decode the alphanumeric variant ID coming from the Shopify GraphQL API using the following code so that the variant Id is the correct format for the API

Buffer(variantId, 'base64').toString('binary').replace(/\D+/g, '')

 

Reply