Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
I am getting inconsistent results with a flow to conditionally display "company" and "address2" values ONLY when present in a shipping address.
For a test order, I am getting the correct results when fulfilling but other orders such as the live one in screenshot are including blank linkes for these fields even though values for "company" and "address2" are NOT present in the shipping addresses. This is with the same liquid conditional:
{{ fulfillmentOrders_item.destination.firstName | capitalize }} {{ fulfillmentOrders_item.destination.lastName | capitalize }}
{%- if fulfillmentOrders_item.destination.company != blank -%}
<br>{{ fulfillmentOrders_item.destination.company }}
{%- endif -%}
<br>{{ fulfillmentOrders_item.destination.address1 }}
{%- if fulfillmentOrders_item.destination.address2 != blank -%}
<br>{{ fulfillmentOrders_item.destination.address2 }}
{%- endif -%}
<br>{{ fulfillmentOrders_item.destination.city }}, {{ fulfillmentOrders_item.destination.province }} {{ fulfillmentOrders_item.destination.zip }}
{%- if fulfillmentOrders_item.destination.countryCode != 'US' -%}
<br>{{ order.shippingAddress.country }}
{%- endif -%}
<br>{{ fulfillmentOrders_item.destination.phone }}
I've spent a lot of time now trying to figure this out and it's frustrating when the test results show success but then real orders are still glitching despite identical code being applied to both. Can anyone help me understand why this code is leaving blank lines for "company" and "address-2" in live orders but not test orders?
Results:
Solved! Go to the solution
This is an accepted solution.
That second screen shot helps. I suspect your blank fields are coming through with spaces, so it passes the blank check and outputs an empty line. You could use something like:
{% assign my_address = fulfillmentOrder_item.destination.address2 | strip %}
{% if my_address != blank %}{{ my_address }}{% endif %}
Another way to do this would be to find and replace all spaces with something you can see (like "X"). That would help troubleshoot.
If you are handy with code, you could also use the GraphiQL app to quickly write a query that gets this data. This is what I do when I suspect whitespace is causing a problem. In the API, it will return in quotes so you can sort of see the spaces.
This has nothing to do with test vs live. The data is different. It's hard to tell how it's different as what you've provided isn't complete.
I would try testing the liquid on the whatever order caused the above to happen according to this doc: https://help.shopify.com/en/manual/shopify-flow/reference/data#use-the-field-in-a-live-workflow
That said, I suspect that you are adding extra whitespace. Since you are using <br />, I would use hyphens on every tag, especially the name and address1
I'll try adding some hyphens but the line breaks are attached to each bit of address data, with the fields in question having their break inside the conditional.
These are all outputs from actual orders, by test I just mean I have an order setup not linked to a real customer and change the shipping address to see results when fulfilling the order (the flow output is an internal email sent, triggered by an order fulfillment). I can cancel fulfillment, change shipping address values, and fulfill again on this order when testing the flow results.
Both of those orders generating the output screenshots on my first post have NO values in the shipping address company, nor address2.... yet one of them has blank lines and the other doesn't based on this same code. Stumped.
here are two orders' worth of inputs and their outputs. I don't understand why the Cletus order correctly omits the blank "company" and "address2" while the Joshua order adds blank lines. Neither order has values in these shipping address fields:
This is an accepted solution.
That second screen shot helps. I suspect your blank fields are coming through with spaces, so it passes the blank check and outputs an empty line. You could use something like:
{% assign my_address = fulfillmentOrder_item.destination.address2 | strip %}
{% if my_address != blank %}{{ my_address }}{% endif %}
Another way to do this would be to find and replace all spaces with something you can see (like "X"). That would help troubleshoot.
If you are handy with code, you could also use the GraphiQL app to quickly write a query that gets this data. This is what I do when I suspect whitespace is causing a problem. In the API, it will return in quotes so you can sort of see the spaces.
Holy cow... that did it!!
I couldn't get the inspect filter to work, it kept kicking an error that it was expecting a different number of arguments, but the strip variables worked!
Still confused why things weren't working as-is, because when I'd output those liquid items into [brackets] they never contained spaces, so I guess something was getting lost in translation from Flow. No idea how I would've figured that out given the output never showed spaces when "blank"... but thanks so much!! This seemingly small glitch has had me aggravated for WEEKS!!
Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024In today’s interview, we sat down with @BSS-Commerce to discuss practical strategies f...
By JasonH Nov 13, 2024