Solved

Back In Stock with woocommerce

  • 28 January 2021
  • 5 replies
  • 201 views

Badge

Hi,

Do somebody find a solution to implement back in stock flow with Klaivyo and Woocommerce ?

natively, it is possible only with shopify.

 

I did it with a List, form and woocommerce hooks but with this method, I have to send email and create new list manualy each time…

 

Regards

icon

Best answer by caroline 5 March 2021, 20:15

Hi there,

It is possible to implement Back in Stock with WooCommerce and Klaviyo using a combination of a custom catalog and API calls. WooCommerce’s standard catalog does not include inventory; as a result, back in stock cannot currently be implemented with the standard WooCommerce catalog. Note: the specifics of setting up a custom catalog for implementing back in stock are covered in our custom catalog documentation, which is not yet publicly facing. If you would like a copy of this information, shoot me a DM.

Once you’ve set up a custom catalog which includes stock for each product, you can make the following API calls to subscribe customers to Back in Stock.

Client-side


$.ajax({
type: "POST",
url: "https://a.klaviyo.com/onsite/components/back-in-stock/subscribe",
data: {
a: "ACCOUNT_ID",
email: "EMAIL",
variant: VARIANT_ID,
product: PRODUCT_ID, // Product must be present in Klaviyo catalog to record event.
platform: "shopify",
subscribe_for_newsletter: false, // Optional with "g". Defaults to false if omitted.
g: "LIST_ID", // Optional with "subscribe_for_newsletter".
},
success: function(response){
console.log(response)
}
})

 

  • a: KLAVIYO_PUBLIC_TOKEN
  • email: the email address of the person (eg. a template tag like {{ email }})
  • g: the ID of the list you want to subscribe them to in addition to the Back in Stock subscription
  • variant: the variant ID of the product (sometimes the same as the product ID)
  • product: the ID of the product
  • platform: the platform from which the request is being sent (we currently accept "shopify", "bigcommerce", or "api")
  • subscribe_for_newsletter: true if you want to subscribe them to a list in addition to the Back in Stock subscription (otherwise false)}

 

Server-side

The API endpoint can allow a platform of api (custom catalogs) or ‘shopify’.  NOTE: if you're using a custom catalog, you'll need to utilize the $inventory_quantity field inside of the custom catalog to track inventory for in/out of stock items

Example call:

curl 'https://a.klaviyo.com/api/v1/catalog/subscribe' --data 'a=AccountID&email=test@klaviyo.com&variant=5000149172256&platform=shopify'

Your POST request must include:

  • a: Your public Klaviyo API Key (6 characters, can be retrieved from https://www.klaviyo.com/account#api-keys-tab)
  • email: The email address entered by the subscriber (must be correctly formatted & valid)
  • variant: The variant ID, for Shopify stores only.
  • platform: shopify

Note: To subscribe a customer to a list as part of the Back In Stock workflow, you will need to make a separate, additional call to our existing List API: https://www.klaviyo.com/docs/api/lists

 

Happy to answer any followup questions.

Best,

Caroline

View original

5 replies

Userlevel 6
Badge +4

@db-conception As far as I know, the Klaviyo public API documentation doesn’t seem to expose this functionality, even for “Custom Ecommerce Integrations.”  For example, this probably has a lot to do with the Catalog Feed Integration for Klaviyo to monitor and check inventory/stock status.  Even the Catalog Integration requires consultation with Klaviyo’s Support Team so it may be possible?

I’d be interested to know if it’s possible too!

 

Userlevel 3
Badge

I never tested myself but maybe there is a workaround with plugins like this 

https://woocommerce.com/products/back-in-stock-notifications/

which will pass the information to Klaviyo and you can set some custom properties and triggers. Just brainstorming. :)

Badge

I never tested myself but maybe there is a workaround with plugins like this 

https://woocommerce.com/products/back-in-stock-notifications/

which will pass the information to Klaviyo and you can set some custom properties and triggers. Just brainstorming. :)

With this solution I will still have to do a lot of custom developments. But if I am not wrong, Klaviyo doens’t provide the way to trigger custom flow on API call. So it’s possible to send may be a campaign but not to start a customizable  flow in Klaviyo.

 

Badge

@db-conception As far as I know, the Klaviyo public API documentation doesn’t seem to expose this functionality, even for “Custom Ecommerce Integrations.”  For example, this probably has a lot to do with the Catalog Feed Integration for Klaviyo to monitor and check inventory/stock status.  Even the Catalog Integration requires consultation with Klaviyo’s Support Team so it may be possible?

I’d be interested to know if it’s possible too!

 

It is strange to see that it is possible for Shopify but not for custom integrations or woocommerce whereas Woocommerce provides webhook for product updated and php hooks for stock changed.:thinking:

 

 

Userlevel 4
Badge +4

Hi there,

It is possible to implement Back in Stock with WooCommerce and Klaviyo using a combination of a custom catalog and API calls. WooCommerce’s standard catalog does not include inventory; as a result, back in stock cannot currently be implemented with the standard WooCommerce catalog. Note: the specifics of setting up a custom catalog for implementing back in stock are covered in our custom catalog documentation, which is not yet publicly facing. If you would like a copy of this information, shoot me a DM.

Once you’ve set up a custom catalog which includes stock for each product, you can make the following API calls to subscribe customers to Back in Stock.

Client-side


$.ajax({
type: "POST",
url: "https://a.klaviyo.com/onsite/components/back-in-stock/subscribe",
data: {
a: "ACCOUNT_ID",
email: "EMAIL",
variant: VARIANT_ID,
product: PRODUCT_ID, // Product must be present in Klaviyo catalog to record event.
platform: "shopify",
subscribe_for_newsletter: false, // Optional with "g". Defaults to false if omitted.
g: "LIST_ID", // Optional with "subscribe_for_newsletter".
},
success: function(response){
console.log(response)
}
})

 

  • a: KLAVIYO_PUBLIC_TOKEN
  • email: the email address of the person (eg. a template tag like {{ email }})
  • g: the ID of the list you want to subscribe them to in addition to the Back in Stock subscription
  • variant: the variant ID of the product (sometimes the same as the product ID)
  • product: the ID of the product
  • platform: the platform from which the request is being sent (we currently accept "shopify", "bigcommerce", or "api")
  • subscribe_for_newsletter: true if you want to subscribe them to a list in addition to the Back in Stock subscription (otherwise false)}

 

Server-side

The API endpoint can allow a platform of api (custom catalogs) or ‘shopify’.  NOTE: if you're using a custom catalog, you'll need to utilize the $inventory_quantity field inside of the custom catalog to track inventory for in/out of stock items

Example call:

curl 'https://a.klaviyo.com/api/v1/catalog/subscribe' --data 'a=AccountID&email=test@klaviyo.com&variant=5000149172256&platform=shopify'

Your POST request must include:

  • a: Your public Klaviyo API Key (6 characters, can be retrieved from https://www.klaviyo.com/account#api-keys-tab)
  • email: The email address entered by the subscriber (must be correctly formatted & valid)
  • variant: The variant ID, for Shopify stores only.
  • platform: shopify

Note: To subscribe a customer to a list as part of the Back In Stock workflow, you will need to make a separate, additional call to our existing List API: https://www.klaviyo.com/docs/api/lists

 

Happy to answer any followup questions.

Best,

Caroline

Reply