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

Can I add a custom customer metafield to an order using Flow?

Solved

Can I add a custom customer metafield to an order using Flow?

PinkProBeauty
New Member
7 0 0

Is it possible to add a custom customer metafield value to the order using Flow? Is there another way to achieve this? 

 

Our CRM has to communicate with Shopify using existing customer identifiers. 

 

Thank you in advance. 

Accepted Solution (1)
Brett_Helium
Shopify Partner
303 58 137

This is an accepted solution.

@PinkProBeauty, to add a value to the order metafield you would want to use the following liquid code, making sure to use the appropriate namespace and key corresponding to your customer metafield.

{%- for metafields_item in customer.metafields -%}
  {%- if metafields_item.namespace == "NAMESPACE"
    and metafields_item.key == "KEY" -%}    
      {{metafields_item.value}}
  {%- endif -%}
{%- endfor -%}

  
Also make sure to use an appropriate metafield type for the data you are trying to add.

Here's an example screenshot: https://share.heliumdev.com/7KuW9YA4

Brett | Helium
- Customer Fields ✪✪✪✪✪ (380 reviews)
- Meteor Mega Menu ✪✪✪✪✪ (307 reviews)
- Onboard B2B NEW!
- Strike Automatic Discounts NEW!

View solution in original post

Replies 15 (15)

paul_n
Shopify Staff
1828 199 435

It's possible to check a customer metafield value when an order is placed, yes. Where would you need to insert the value?

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.
PinkProBeauty
New Member
7 0 0

Thank you for replying Paul! 

 

I need the value of the custom customer metafield to be inserted on the order itself. 

 

Basically I need my CRM to recognize the Shopify order came from that specific customer that has a pre assigned customer number by the CRM. We uploaded all of those customer numbers as custom metafields to the customer profilles, I just need whenever an order is created for that customer metafield to attach to the order so whenever it is exported, it will be visible on the spreadsheet to use as the common identifier. 

paul_n
Shopify Staff
1828 199 435

So I don't know what fields your CRM imports. Also, you may run into an issue where the CRM imports the order before the order is updated. Currently, the three places you can add additional info to an order, via Flow, are the order note, order tags, or order metafields.

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.
PinkProBeauty
New Member
7 0 0

We have to manually set the schedule for imports. I found the update order metafields, but I can't seem to get it to add the customer metafield. Could you assist further with this? I really appreciate your assistance. 

Brett_Helium
Shopify Partner
303 58 137

This is an accepted solution.

@PinkProBeauty, to add a value to the order metafield you would want to use the following liquid code, making sure to use the appropriate namespace and key corresponding to your customer metafield.

{%- for metafields_item in customer.metafields -%}
  {%- if metafields_item.namespace == "NAMESPACE"
    and metafields_item.key == "KEY" -%}    
      {{metafields_item.value}}
  {%- endif -%}
{%- endfor -%}

  
Also make sure to use an appropriate metafield type for the data you are trying to add.

Here's an example screenshot: https://share.heliumdev.com/7KuW9YA4

Brett | Helium
- Customer Fields ✪✪✪✪✪ (380 reviews)
- Meteor Mega Menu ✪✪✪✪✪ (307 reviews)
- Onboard B2B NEW!
- Strike Automatic Discounts NEW!
PinkProBeauty
New Member
7 0 0

This worked like MAGIC! 

Thank you so much. We're also Helium customers as well 🙂 

Brett_Helium
Shopify Partner
303 58 137

Using Liquid in Shopify Flow can definitely be a bit tricky, but I'm glad to hear that worked for you!

And thanks for using our apps, we're always glad to hear that 😁

Brett | Helium
- Customer Fields ✪✪✪✪✪ (380 reviews)
- Meteor Mega Menu ✪✪✪✪✪ (307 reviews)
- Onboard B2B NEW!
- Strike Automatic Discounts NEW!
rohit-world
Shopify Partner
8 0 1

rohitworld_0-1712925694902.png

Please help me fixing this problem

i am trying to update a metaField of order on order creation using customer metafields 

there is a metafield already in customers i want to assign that with orders.

gr_trading
Shopify Partner
2070 149 212

Hi @PinkProBeauty 

 

You can use the below code to implement the same

 

{% if customer.metafields.register.company != blank %}
<input type="text" name="attributes[crm_attribute]" form="cart" value="{{customer.metafields.register.company}}" />
{% endif %}

 

customer.metafields.register.company is metafield name replace it with your value.

 

Hope this will help...

For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
paul_n
Shopify Staff
1828 199 435

This is asked for Shopify Flow. I think your solution here is to customize the checkout liquid.

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.
gr_trading
Shopify Partner
2070 149 212

no this is a cart page modification.

 

Please refer the below article for more details

 

https://shopify.dev/docs/themes/architecture/templates/cart

For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee
PinkProBeauty
New Member
7 0 0

Thank you! I will have IT try this method momentarily. 

PinkProBeauty
New Member
7 0 0

Where exactly do I need to put this code? It's giving me an error when I add it to the cart.json 

gr_trading
Shopify Partner
2070 149 212

main-cart-footer.liquid

For any custom development WhatsApp or connect at Email ID: support@grtrading.in for quick consultation. | Shopify Free codes
To support Buy Me a Coffee

paul_n
Shopify Staff
1828 199 435

Flow just launched improved metafield support, which makes it easier to find and use metafield data in Flow: https://changelog.shopify.com/posts/shopify-flow-access-typed-metafields

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.