If then logic in liquid for shopify flow

New Member
4 0 1

On shopify flow i need to put dynamic content using liquid into a post request.

The logic specifically needs to be 

If {{order.customerJourneySummary.lastVisit.referralCode}} exists, then use {{order.customerJourneySummary.lastVisit.referralCode}}.  Else {{order.customerJourneySummary.firstVisit.referralCode}}

From my understanding if there is only one visit, only the firstvisit field is populated.  We are trying to do last touch attribution which requires only the LAST referral code to be recorded.  So this logic is necessary to ensure that if there is only one visit the post request still works.  

Thanks in advance,

Replies 2 (2)
95 0 15

I also want to know how to solve this problem!

Shopify Staff
Shopify Staff
45 16 13

Hi WrdMax,


You should be able to write a regular if statement inside the HTTP request body, like

{% if order.customerJourneySummary.lastVisit.referralCode %}{{order.customerJourneySummary.lastVisit.referralCode}}{% else %}{{order.customerJourneySummary.firstVisit.referralCode}}{% endif %}

Just watch out for whitespace and quotes and stuff depending on how your request is being formatted.


Hope that helps!

DaveMcV | Flow Development Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.