Skip to main content
Contributor I
January 28, 2021
Solved

Back In Stock with woocommerce

  • January 28, 2021
  • 15 replies
  • 4823 views

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

    Best answer by caroline

    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

    15 replies

    Contributor I
    June 23, 2023
    It would be great to develop this flow for Woocommerce users who trust Klaviyo.
    Active Contributor I
    October 17, 2023

    With the new API releases, is there any improvement on setting up an easier Back in Stock flow with WooCommerce? Or ideally a native solution as you see with Shopify, is this on the roadmap at all?

    Is there yet any native integration to the Klaviyo WordPress plugin for this functionality, or is it still custom catalog and API required?

    Contributor I
    October 16, 2024

    This seems like something that should definitely be worked on at this point by Klaviyo. Is there any update from the Klaviyo team? 

    Contributor I
    October 16, 2024

    Digging into this one, it seems like it should be possible to use custom catalog feed to pull in the inventory and build the flow using that. Here’s the documentation that I’ve found that should be helpful.

    https://developers.klaviyo.com/en/docs/guide_to_syncing_a_custom_catalog_feed_to_klaviyo

    https://help.klaviyo.com/hc/en-us/articles/115003872251

    https://developers.klaviyo.com/en/docs/how_to_enable_back_in_stock_for_custom_catalog_feeds

     

    I hope that helps everyone who is looking to this thread for info!

    Contributor I
    April 11, 2025

    I was able to build a WooCommerce plugin for this, but I’m not using the catalog feed. I’m not entirely sure if this is the best approach, but here’s how it works:

    • When a product is marked as out of stock, the plugin creates a list and a campaign in Klaviyo. It then stores the list ID and campaign ID as product meta(Two API calls ).

    • A form is displayed on the product page when the product is out of stock.

    • When someone signs up using the form, a profile is created and added to the list based on the stored list ID. (This process is handled in a single API request.)

    • When the product is marked as in stock, the plugin updates the email template and triggers the campaign via the Klaviyo API(3 API calls).

    It’s working well for me, but I’m still unsure if this is considered best practice. Currently, the plugin is only being used internally by my employer.