By default, abandonment emails include both in-stock and out-of-stock items.
To prevent out-of-stock products from appearing, exclude them from the cart layout and add a filter to the trigger to check that at least one in-stock item is included. This prevents sending an empty email.
Before you start
Things you need to know:
To hide an out-of-stock product, you must ensure that the stock quantity or status is being collected.
Use the Products rule
Go to Triggers in the left side menu.
Expand the Show options (three dots) menu for the trigger you want to edit and select the Edit icon.
βExpand the Raised Browse/Cart Abandon Signal rule group and drag the Products rule to the top of the rule tree on the right, so it's the first entry.
Select the rule to configure and set the options to
all of
Stock
Out of Stock
respectively.
If a cart matches that criteria, this means all of the items in it are of out of stock, so you don't want to send.
Select the Add Trigger Program tab and drag the Do Nothing trigger into the Yes branch. Then add any other rules/triggers to the No branch.
Check stock before sending each stage
This method decides whether to add the person to the trigger program initially. To check before sending each stage of a multi-stage trigger, enable the Refresh product data at send time option and add the following script to the script box for the stage:
result.proceed = false;
if (helpers.checkCartStock() === true){
result.proceed = true;
}
Example for the second stage email:
Cart Layout
To hide out-of-stock products in a cart layout, modify the product FOR loop and append the below IF statement:
{% for product in products if product.stock > 0 %}
If using an existing filter to limit the number of products returned, append the IF statement to the end:
{% for product in products|limit(1)|reverse if product.stock > 0 %}