What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: How can update Customer Metafield when checkout successfully

How can update Customer Metafield when checkout successfully

nhtbao101
Tourist
14 0 2

This is the first time I am working with Shopify, please help me with this case.
I am using points in the customer metafield to discount for an order when the customer checkout. But I don't know how to update customer metafield on checkout page
I want to know how can I update the customer metafield after I checkout an order or submited an order successfully?
If possible, how can we do that? Thank you so much

Replies 7 (7)

Liam
Community Manager
3108 344 895

Hi Nhtbao101,

 

Just to understand your use-case fully - do you want to update the customer metafield during the checkout process, or after - ie: once the order is processed? When do you want the discount to be applied? 

 

Once I have a little bit more info I can recommend the best approach! 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

nhtbao101
Tourist
14 0 2

Thank you for your reply.
About the discount, I applied it in Step-1 (checkout information) and after the order is processed, I will update the customer metafield at the moment. In addition, I want to update real-time, it's means, I will update customer Metafield immediately when the order is processed successfully. Because when the app have delay when updating discount point for the customer, they can trick to steal money of the store (order in 2 devices at the same time)

Liam
Community Manager
3108 344 895

There is a function for useApplyMetafieldsChange() that you can use to mutate the metafields property of the checkout - would this work in your usecase? You can see an example of how it's implemented in this tutorial.

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

nhtbao101
Tourist
14 0 2

Thanks again for your reply.

I read the docs about useApplyMetafieldsChange(). And I see this line 
"This metafield value is later associated with the order". In 
In this link 
Does this mean this function just works with the order and cart only or I am wrong? Can you confirm about it?

 
 
nhtbao101
Tourist
14 0 2

@Liam 
I just want to update customer metafield in checkout UI extension  🙁

Cpuga
Shopify Partner
43 0 7

Im trying the same any way to do it?

nhtbao101
Tourist
14 0 2

@Cpuga 
No, You cannot update customer metafield on the checkout page.
I use another method by saving the order information to DB when checkout and updating it to the customer metafield in the next date by automatic API