Skip to main content
Solved

back in stock button on product card

  • September 20, 2023
  • 1 reply
  • 464 views

Forum|alt.badge.img+1

Hoàng

Klaviyo has this code to show the back in stock button, but is there any way to show this button outside the home page, product card or is the product taken from other sections, for example recommending products section  from shopify? Pls i really need a help

 

<script src="https://a.klaviyo.com/media/js/onsite/onsite.js"></script>

<script defer>

    var klaviyo = klaviyo || [];

    klaviyo.init({

      account: "",

      platform: "shopify",

      collection_urls: ["/products/"]

    });

    klaviyo.enable("backinstock",{

    trigger: {

      product_page_text: "Notify Me When Available",

      product_page_class: "btn",

      product_page_text_align: "center",

      product_page_margin: "0px",

      replace_anchor: false

    },

    modal: {

    headline: "{product_name}",

    body_content: "Register to receive a notification when this item comes back in stock.",

    email_field_label: "Email",

    button_label: "Notify me when available",

    subscription_success_label: "You're in! We'll let you know when it's back.",

    footer_content: '',

    additional_styles: "@import url('https://fonts.googleapis.com/css?family=Helvetica+Neue');",

    drop_background_color: "#000",

    background_color: "#fff",

    text_color: "#222",

    button_text_color: "#fff",

    button_background_color: "#439fdb",

    close_button_color: "#ccc",

    error_background_color: "#fcd6d7",

    error_text_color: "#C72E2F",

    success_background_color: "#d3efcd",

    success_text_color: "#1B9500"

    }

  });

</script>

 

Best answer by Brian Turcotte

Hi @HoangYho!
 

The back-in-stock functionality is only intended to work on product pages, so there is not a Klaviyo-supported way to change its behavior. However, it may be possible to have the back-in-stock module appear on other pages or locations on your site, but this will depend largely on how your e-commerce site is set up. One way could be to add an additional script to your theme files, changing the collections tag from products to the desired slug:

 

 

If you’re looking for further development help, you’re always welcome to reach out to one of our wonderful official Klaviyo Partners!

 

Best,

Brian

View original
Did this topic or the replies in the thread help you find an answer to your question?

1 reply

Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • September 20, 2023

Hi @HoangYho!
 

The back-in-stock functionality is only intended to work on product pages, so there is not a Klaviyo-supported way to change its behavior. However, it may be possible to have the back-in-stock module appear on other pages or locations on your site, but this will depend largely on how your e-commerce site is set up. One way could be to add an additional script to your theme files, changing the collections tag from products to the desired slug:

 

 

If you’re looking for further development help, you’re always welcome to reach out to one of our wonderful official Klaviyo Partners!

 

Best,

Brian