Question: How do I prevent Shipping Insurance from displaying in my abandoned cart SMS message?
My abandoned cart is set up to display the product name and image for the first item in the cart. What if that item is Shipping Insurance? Can I have it “skip” that item and display something else?
Answer:
Great question! Typically, you can display the product name for the first item in the cart by using the tag {{ event.Items.0 }}. You can similarly display an image for this product with the tag {{ event.extra.line_items.0.product.images.0.src }}.
These tags display product 0, which is the first item in the cart.
If the first item is shipping insurance (or any other product you want to exclude), you may want to display the second item instead. You can use if/else logic to achieve this:
- Product Name:
{% if event.extra.line_items.0.product.title == "Name_of_Excluded_Product" %}{{ event.extra.line_items.1.product.title }}{%else%}{{ event.extra.line_items.0.product.title }}{%endif%}
- Image:
{% if event.extra.line_items.0.product.title == "Name_of_Excluded_Product" %}{{ event.extra.line_items.1.product.images.0.src }}{%else%}{{ event.extra.line_items.0.product.images.0.src }}{%endif%}
For additional information:
Note that this example uses the tags needed for a flow triggered by Shopify’s Checkout Started event. If you are using a different trigger event, the code may need to be modified.