You will learn

Learn how to skip Shopify abandoned cart or browse abandonment emails when a featured product is unavailable in your Klaviyo catalog by updating the dynamic content in your emails.

If you often sell out of popular items, it's possible that a customer will place an item in their cart one minute and come back hours later to find the same item out-of-stock. While abandoned cart and browse abandonment flows can drive significant revenue to your business, fast selling inventory can make it challenging to send reminders that don't fall flat. Encouraging customers to return to a cart full of out-of-stock items can lead to a frustrating customer experience.

Before you begin

If you have not already, read our guide on getting started with Shopify for step-by-step instructions on integrating, before continuing with this article.

Before following the steps in this article, it's important to note the following:

  • Klaviyo only marks Shopify products as unpublished in its catalog because of low inventory if customers cannot purchase them when they are out of stock. This does not unpublish the products from your Shopify store.
  • If you have multiple variants of a product, all variants must be out of stock and unavailable for purchase for Klaviyo to mark the entire product as unpublished. The snippets below check the product, so an unavailable variant alone will not cause the email to be skipped if another variant is still available.

The abandoned cart flow

Klaviyo's default abandoned cart email templates (for our abandoned cart flow triggered by Checkout Started) feature a dynamic table that is used to populate each email with the specific items the recipient left behind in their abandoned cart.

If you would like an abandoned cart email to automatically be canceled if it is going to feature one or more items that have since gone out-of-stock, you will need to adjust the image section of the existing dynamic table in a given template.

  1. In Flows, open your abandoned cart flow, select the email you want to update, and click Edit on its template.
  2. Click the table containing your product details. Under Content, use Cell selector to select the cell containing the product image.
  3. Under Cell content, change the cell from Image to HTML.
Table content editor with 'Image' selected for cell content.
  1. Replace the contents of the HTML editor with the following snippet.
UI showing HTML option selected and the code `<p>This is an HTML cell.</p>`.
text
{% catalog item.product_id unpublished="cancel" %} 
<a href="{{ event.extra.responsive_checkout_url }}"> 
<img alt="" src="{{ catalog_item.featured_image.thumbnail.src }}" style="width: 200px;" width="200px" /></a> 
{% endcatalog %}
  1. When you have finished editing, click Exit to save your changes and leave the editor.
  2. Repeat these steps for each email in the flow that should skip unavailable products.

This code will ensure that:

  • Before a given email in your flow is scheduled to send, Klaviyo will look up each item that will dynamically populate in the individual email.
  • If any one item is "unpublished" in your catalog at time of lookup, the entire email will get skipped.

Select the email in your flow, then click View details under Performance. Go to Recipient activity > Skipped and select Skipped: Catalog Item Unavailable. This category includes emails skipped because a featured product was unpublished or no longer in your catalog.

It is not possible to remove a single out-of-stock item from an email and send the rest of the email as scheduled. If at least one item in a cart has gone out of stock, the entire email will be canceled.

Check the return-to-cart link

If the Return to Cart button links to the wrong page, check that it uses the checkout link from the event. Shopify currently supplies the same link for both checkout variables shown below, so switching between them will not fix an incorrect link when their values match.

  1. In Klaviyo, open the abandoned cart flow email template you wish to edit.
  2. Click the Return to Cart button in the template to edit its Link address.
  3. Set Link address to the checkout variable below if the button does not already use a checkout link:
text
{{ event.extra.checkout_url }}

The following variable also contains the checkout link:

text
{{ event.extra.responsive_checkout_url }}
  1. The image below shows an example.
  1. Click Preview, select a recent checkout event, and check the button’s destination. After closing the preview, click Exit to save any changes.

The browse abandonment flow

Klaviyo’s browse abandonment email templates use dynamic product details to show the specific item a recipient viewed on your website. The steps below apply to a template with those details in a table block.

If you would like browse abandonment emails to automatically be canceled if they are going to feature an item that has since gone out-of-stock, you will need to adjust the image section of the existing table in a given template.

  1. In Flows, open your browse abandonment flow, select the email you want to update, and click Edit on its template.
  2. Click the table containing your product details. Under Content, use Cell selector to select the cell containing the product image.
  3. Under Cell content, change the cell from Image to HTML.
  1. Replace the contents of the HTML editor with the following snippet.
text
{% catalog event.ProductID unpublished="cancel" %} <a href="{{ catalog_item.url }}"><img src="{{ catalog_item.featured_image.full.src }}" style="width: 200px;" width="200px" /></a> {% endcatalog %}
  1. When you have finished editing, click Exit to save your changes and leave the editor.
  2. Repeat these steps for each email in the flow that should skip unavailable products.

This will ensure that:

  • Before a given email in your flow is scheduled to send, Klaviyo will look up the item that will dynamically populate in the individual email.
  • If this item is "unpublished" in your catalog at the time of lookup, the email will be skipped.

Select the email in your flow, then click View details under Performance. Go to Recipient activity > Skipped and select Skipped: Catalog Item Unavailable. This category includes emails skipped because a featured product was unpublished or no longer in your catalog.

How to test your out-of-stock feature

You can test this feature by:

  1. Adjust your email templates as explained above.
  2. View an item on your site and/or start a checkout with a single item in your cart.
  3. Go to Analytics > Metrics and confirm that your test event appears in the relevant metric.
  4. Temporarily set the test product’s inventory to 0 in Shopify, including all variants, and make sure it cannot be purchased when out of stock. Allow the product update to sync to Klaviyo before checking the email preview.
  5. Open the flow triggered by your test event (Viewed Product or Checkout Started) that contains the updated email templates.
  6. Open the email editor and click Preview. Use the event selector to choose your own recent test event.
  7. For an unpublished product, the preview should show Item (Number) is not published and unavailable. in place of its image. If the image still appears, confirm that all variants are unavailable and allow the catalog update to sync before reopening the preview.
Example email preview in Klaviyo showing block with item unavailable, outlined in red
Example email preview in Klaviyo showing block with item unavailable, outlined in red
  1. After testing, restore the product’s original inventory settings in Shopify.

Outcome

You've now learned how to skip Shopify abandoned cart and browse abandonment emails when a featured product is unavailable in your Klaviyo catalog, and how to test the setup.

Additional resources

Was this article helpful?
Use this form only for article feedback. Learn how to contact support.

Explore more from Klaviyo

Community
Connect with peers, partners, and Klaviyo experts to find inspiration, share insights, and get answers to all of your questions.
Partners
Hire a Klaviyo-certified expert to help you with a specific task, or for ongoing marketing management.
Support

Access support through your account.

Email support (free trial and paid accounts) Available 24/7

Chat/virtual assistance
Availability varies by location and plan type