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,
platform: "shopify",
subscribe_for_newsletter: false,
g: "LIST_ID",
},
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