Abandoned Cart SMS - Exclude product

  • 29 September 2022
  • 4 replies
  • 179 views

Userlevel 7
Badge +60

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. 


4 replies

Badge +1

Hi there! 

 

I’m running into a similar problem, but with a product that is not always listed as “0”. We have two sample products that customers can add on to their purchase at checkout. We don’t want these sample products to be shown in our SMS replenishment flow. Any ideas how we can fix this if the product is not always the same item number in the array? 

Userlevel 7
Badge +60

Hey @meredith88acres,

If the product you want to exclude isn’t always in the 0 position, you can always evaluate the logic at a higher level. This means, instead of always checking to see if a specific product is in the 0 position, you can check to see if a specific product is present in an array/list of products. 

I would recommend checking out the Community post I linked below which talks about a similar subject:

I hope this helps!

David

Badge +1

Hey @David To how would this be accomplished in an SMS flow rather than email?

Userlevel 7
Badge +60

Hey @meredith88acres,

The concept would be the same - even in an SMS message. It would all be based on the conditional logic you’re writing. 

Our template expert, @Anna McCarthy has a great tutorial on how to formulate your own if/else logic statements in the Community post I shared below which I think you’ll find helpful:

David

Reply