Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello Shopify Community,
I’m working on a task where I need to update a custom integer customer metafield when an order is created and has the tag “fulfilled”.
Here’s what I’ve done so far:
1. Created the Customer Metafield:
• Name: custom
• Namespace and Key: custom.orders
•Type: Integer
2. Set Up Shopify Flow:
•Trigger: Order Created.
•Condition: Check if Order Tags contains “fulfilled”.
•Action: Update the customer metafield custom.orders by incrementing its value by 1.
However, when setting up the flow, I encountered the following error: "custom" is invalid. Replace this variable.
Detailed Steps in Shopify Flow:
1. Trigger: Order Created.
2. Condition: Order Tags contains “fulfilled”.
3. Action: Update Customer Metafield:
• Namespace: custom
• Key: custom.orders
• Value: {{ order.customer.metafields.custom.custom.orders | default: 0 | plus: 1 }}
•Type: Integer
Error Encountered:
The specific error message I’m receiving is:
"custom" is invalid. Replace this variable.
Request for Assistance:
Can anyone help me understand what might be causing this error and how I can resolve it? Any advice on the correct setup or common pitfalls to avoid would be greatly appreciated.
Thank you in advance for your help!
Additional Information:
•I’m using Shopify Plus.
•The goal is to track the number of fulfilled orders for each customer using a custom metafield.
Hi @divyaneelam 👋Thanks you so much for the great detail of your issue, very refreshing to see.
The key is "orders" NOT "custom.orders" "custom" is the namespace , based on the description and 2nd image showing the value of the flow actions key field and error message.
So it's {{ order.customer.metafields.custom.orders | default: 0 | plus: 1 }} , NOT "{{ order.customer.metafields.custom.custom.orders | default: 0 | plus: 1 }}"
⚠️You may also need to use the .value property for some metafield types {{ order.customer.metafields.namespace.key.value }}
I also recommend doing the hard work of naming things for better contexts now or in the future.
You want to be able to use metafields verbally or describing business logic without ambiguities.
Renaming it to something like reporting.fulfilled_orders_count , or stats.fulfilled_orders_count , fulfillment.fulfiled_orders_count etc.
Something that makes sense for the purpose of what's being made as a statement.
As you grow custom.orders kinda implies that some custom order action has occurred, such as an order was edited by staff or product personalization , for all the orders in that metafields orders value, but the values aren't actually "orders" objects or id references it's just a number count.
The custom thing is just a placeholder when metafields are being made and a clue better naming is warranted.
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
Metafields cannot be accessed the same way in Flow as they are in theme liquid (using something like order.namespace.key).
To access a single metafield value, you click "Add a variable" and then click find the "metafield" variable (note: not the plural metafields). It will guide you to choose your metafield and add it to the environment.
Once you do that, Flow stores that metafield type for the workflow and it will be accessible to other steps as a variable in the picker.
Doc page that outlines this: https://help.shopify.com/en/manual/shopify-flow/reference/metafields#get-metafield-data