Compare customer's new order to customer's previous order

Solved

Compare customer's new order to customer's previous order

hostilearth
Shopify Partner
39 0 6

I did not know there was a Flow App community here. I've been posting my (unanswered) questions to the Shopify Apps community.

 

Here are my last two posts (I don't see how to move them) related to this post:

Since I couldn't get either of those methods to work, I started on a third. It starts with getting the customer's order data, then looping through the orders. I can't just get the latest order data (i.e., 1) because the latest order is the order just placed and which triggered the flow and not the order just before (i.e., the true previous order).

 

This method works until I go to tag the original order (i.e., the order that triggered the flow). Because I'm looping through the order data, I can only tag action on an order from the get order data - I cannot take an action on anything not in the loop.

 

Screenshot 2023-10-25 173723 - Copy.png

Accepted Solution (1)
paul_n
Shopify Staff
1150 142 273

This is an accepted solution.

Wouldn't you do something like:

date_created:<={{ "now" | date_minus:"1 minute" }} 

Paul_N | Flow Product 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.

View solution in original post

Replies 11 (11)

paul_n
Shopify Staff
1150 142 273

Can you use the "Then" path? That path will be executed after the looping is done and you'll have access to the original order

Paul_N | Flow Product 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.
hostilearth
Shopify Partner
39 0 6

Hi. Thank you for helping. I am using the then path at the end. Using then instead of otherwise at any point during the for each loop does not allow me to edit the original triggering order. 😫

 

If you mean "then" at the for each block, that doesn't loop through the options, therefore, doesn't accomplish what I need.

paul_n
Shopify Staff
1150 142 273

I think I understand...you want to conditionally tag an order based on other orders. 

 

The most straight-forward way to do that is to remove the whole For Each loop and connect an "Add Order Tag" to "Get Order Data". You then write your logic in Liquid in the tag field (yes it accepts liquid). 

 

A couple of tips:

  1. Get the logic/whitespace/etc right first by using Log Output instead of Add order tags.
  2. Then copy the code into the tag and hit enter.
  3. I usually save it in the description as well in case I need to later edit it (tag fields aren't editable) although you could keep the Log Output in there for the same purpose.
Paul_N | Flow Product 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.
hostilearth
Shopify Partner
39 0 6

Thank you. I understand conceptually what you're suggesting, but don't know how to pull it off.

 

Today, I've been focusing on the get order data query. If I could change the "now" to "1 minute" (or equivalent) so the newest order (the trigger order) was excluded, it would solve my problem; however, "now" doesn't seem to be replaceable.

paul_n
Shopify Staff
1150 142 273

{{ "now" | date_minus:"1 min" }} 

 

Paul_N | Flow Product 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.
hostilearth
Shopify Partner
39 0 6

That just gives from now to 1 minute ago...which will just be the current new order that triggered the flow.

paul_n
Shopify Staff
1150 142 273

This is an accepted solution.

Wouldn't you do something like:

date_created:<={{ "now" | date_minus:"1 minute" }} 

Paul_N | Flow Product 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.
hostilearth
Shopify Partner
39 0 6

The problem is "now." It means all orders from the 1st to date_minus will be pulled. I tried ">" without the "=", which means anything greater than now and less than date_minus, but it still grabbed the latest more recent order that triggered the flow.

paul_n
Shopify Staff
1150 142 273

Can you share your full query?

Note that I used "less than" so that code would get all orders older than 1 minute. 

Paul_N | Flow Product 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.
hostilearth
Shopify Partner
39 0 6

This does work! While I noticed the less than operator, I failed to see less than with time means anything older than.

 

BTW: "1 min" generates an error but "1 minute" works.

 

Thank you very much for sticking with your help.

paul_n
Shopify Staff
1150 142 273

Great thanks I fixed the original post

Paul_N | Flow Product 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.