Re: Question about "Send email summary with all unfulfilled orders older than 2 days" temp

Solved

Question about "Send email summary with all unfulfilled orders older than 2 days" template

scamby
Tourist
7 0 2

In the second step of the template (which I have changed from 2 days to 3), I want to only return orders that are unfulfilled, paid, not a test, not closed, not archived and not cancelled (i.e. truly active orders).  Currently, I have only been able to get it to return unfulfilled and paid orders.  How would I change the query shown to return what I need?

 

Screenshot 2023-10-20 113813.png

 

Accepted Solutions (2)

DaveMcV
Shopify Staff
104 31 30

This is an accepted solution.

Hi Scamby,

 

Maybe try something like this:

created_at:<='{{ scheduledAt }}' AND created_at:>'{{ scheduledAt | date_minus: "3 days" }}' AND financial_status:paid AND fulfillment_status:unfulfilled AND test:0 AND closed:0 AND cancelled:0

 

This query field uses the the Shopify Search API Syntax in case you need to make any more tweaks.

 

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.

View solution in original post

DaveMcV
Shopify Staff
104 31 30

This is an accepted solution.

With the liquid limitations, you might have to look into something using the modulo operator, like this:

{% for order_item in getOrderData %}
{%- assign ones_column_cents = order_item.currentTotalPriceSet.shopMoney.amount | times: 100 | round | modulo: 10 -%}

{%- if ones_column_cents == 0 -%}
    {% assign extra_zero = '0' -%}
{%- else -%}
    {%- assign extra_zero = '' -%}
{%- endif -%}

{%- assign order_amount = order_item.currentTotalPriceSet.shopMoney.amount | append: extra_zero -%}
{{order_item.name}} - ${{order_amount}}
{% endfor %}

 

That worked for me on my shop at least.

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.

View solution in original post

Replies 13 (13)

DaveMcV
Shopify Staff
104 31 30

This is an accepted solution.

Hi Scamby,

 

Maybe try something like this:

created_at:<='{{ scheduledAt }}' AND created_at:>'{{ scheduledAt | date_minus: "3 days" }}' AND financial_status:paid AND fulfillment_status:unfulfilled AND test:0 AND closed:0 AND cancelled:0

 

This query field uses the the Shopify Search API Syntax in case you need to make any more tweaks.

 

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.
scamby
Tourist
7 0 2

That fixed my selection issue.  Now, I just need to know how to format the email it sends so that the order amount is formatted as currency.  Here is what my code for the email body looks like -

 

The unfulfilled orders (order number - amount):
{% for order_item in getOrderData %}
{{order_item.name}} - ${{order_item.currentTotalPriceSet.shopMoney.amount}}
{% endfor %}

 

But in the resulting email, any orders that have a 0 in the second position after the decimal in the price look like this -

 

255637 - $80.4

255638 - $56.0

paul_n
Shopify Staff
1675 183 385

Round might work:

https://shopify.github.io/liquid/filters/round/

Something like:

| round: 2

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.
scamby
Tourist
7 0 2

No, that gave the same result.

DaveMcV
Shopify Staff
104 31 30

With the liquid limitations, you might have to look into something using the modulo operator, like this:

{% for order_item in getOrderData %}
{%- assign ones_column_cents = order_item.currentTotalPriceSet.shopMoney.amount | times: 100 | round | modulo: 10 -%}

{%- if ones_column_cents == 0 -%}
    {% assign extra_zero = '0' -%}
{%- else -%}
    {%- assign extra_zero = '' -%}
{%- endif -%}

{%- assign order_amount = order_item.currentTotalPriceSet.shopMoney.amount | append: extra_zero -%}
{{order_item.name}} - ${{order_amount}}
{% endfor %}

 

That worked for me on my shop at least.

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.
DaveMcV
Shopify Staff
104 31 30

This is an accepted solution.

With the liquid limitations, you might have to look into something using the modulo operator, like this:

{% for order_item in getOrderData %}
{%- assign ones_column_cents = order_item.currentTotalPriceSet.shopMoney.amount | times: 100 | round | modulo: 10 -%}

{%- if ones_column_cents == 0 -%}
    {% assign extra_zero = '0' -%}
{%- else -%}
    {%- assign extra_zero = '' -%}
{%- endif -%}

{%- assign order_amount = order_item.currentTotalPriceSet.shopMoney.amount | append: extra_zero -%}
{{order_item.name}} - ${{order_amount}}
{% endfor %}

 

That worked for me on my shop at least.

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.
scamby
Tourist
7 0 2

That worked, thanks.

jsciabica
Excursionist
29 0 76

This is returning only orders placed within the last 3 days for me. What change to I need to make to EXCLUDE orders placed within the last 3 days?

paul_n
Shopify Staff
1675 183 385

You just change the operator on the date and remove the other created_at filter

created_at:<='{{ scheduledAt | date_minus: "3 days" }}'
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.
CarmineT
Shopify Partner
96 2 34

unfortunately I tested many times this query and always filter order from the moment it run.

So in practice does not do what asked

paul_n
Shopify Staff
1675 183 385

This query will return all results when a filter has an error. So you have an error in your query

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.
leon99
Tourist
6 0 1

Hi all,

I have set up a similar flow, but the email it's producing has no data in it? 

Could some please help me and explain where the flow has gone wrong? 

leon99_1-1728634466041.png


The email has the subject and email and that's it. 

leon99_2-1728634511299.png

 

 

Thanks!

paul_n
Shopify Staff
1675 183 385

Use have a bunch of filters in there that are not filters. And you put in values of 0 instead of false. These filters are now documented better here: https://shopify.dev/docs/api/admin-graphql/2024-10/queries/orders#argument-query-filter-test

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.