[Admin or Storefront API] Possibility to store custom fields

mlo
Excursionist
17 0 4

Hey everyone,

When one of my customer buy an item, I need to save a 'parcelMissionId' key/value so when the user comes to his page account, he can follow the progress of his package ('parcelMissionId' is an id using by the package provider, I can use this ID to retrieve the parcel).

When the user hits 'www.myshop.com/profile/orders', I need to retrieve this 'parcelMissionId'. 

Is there a way to store that kind of informations in the Customer or Order resource? (Admin or Storefront API)

 

Many thanks

Replies 4 (4)

Kyle_W
Shopify Expert
172 26 105

Hi @mlo!

You can store additional information for most Shopify resources (including Customer and Order) using Shopify's concept of metafields. Metafield data can be created or updated using an app or the Admin API, and once metafields are saved into Shopify they can be accessed on the storefront using Liquid. I've provided some links below with more details:

https://shopify.dev/docs/admin-api/rest/reference/metafield

https://shopify.dev/docs/themes/liquid/reference/objects/metafield

Hopefully this helps!

Kyle W | Helium
Helium builds apps that thousands of merchants depend on:
- Customer Fields ✪✪✪✪✪ (300+ reviews)
- Meteor Mega Menu ✪✪✪✪✪ (200+ reviews)
mlo
Excursionist
17 0 4

Hey @Kyle_W thanks for your response ! 

You can store additional information for most Shopify resources (including Customer and Order) using Shopify's concept of metafields. Metafield data can be created or updated using an app or the Admin API, and once metafields are saved into Shopify they can be accessed on the storefront using Liquid. I've provided some links below with more details:

 

I know that they are some metafields. I have some questions for you:

1. Can I update and custom that fields per Customer? I mean, is it possible to create, per example for three users, something like: 

customer1: 

"metafields": [

 "customField": { "foo1": "bar1"} 

]

 

customer2: 

"metafields": [

 "customField": { "foo2": "bar2"} 

]

 

customer3: 

"metafields": [

 "customField": { "foo3": "bar3"} 

]

 

2. How can I know when a transaction is paid or not? I mean, how can I know if a transaction is accepted or not, when a user come back to the website after the payment using the webUrl provided by Shopify using third part payment (vivawallet). The user is basically redirecting with an url looking like www.shop.myshopify.com/123456/checkouts/123456eaer1234/...

I need to know what the slug following checkouts is corresponding. 

 

Is it clear for you ? 

 

Many thanks for your response 🙂

 

 

Kyle_W
Shopify Expert
172 26 105

You're most welcome, @mlo!

Yes, you can create and update metafields for each resource. In your case you can use the same namespace for each customer record, and the data within the metafield can be unique to each customer.

If the transaction is successful, Shopify will show the user an "order status" page on the final section of the checkout page. You can use Shopify's 'additional scripts' setting to customize the order status page to add things such as conversion tracking or dynamic content. Here is a page on Shopify's docs with more details: https://help.shopify.com/en/manual/orders/status-tracking/customize-order-status

Kyle W | Helium
Helium builds apps that thousands of merchants depend on:
- Customer Fields ✪✪✪✪✪ (300+ reviews)
- Meteor Mega Menu ✪✪✪✪✪ (200+ reviews)
mlo
Excursionist
17 0 4

Thanks a lot, again @Kyle_W ! 
your responses are very clear. 
however, I’m using Storefront and Admin API with a react app  

I want to use not Vivawallet - as I said by mistake in my first post - but PayGreen which is not a third payment partner to shopify. I also want to use a delivery service (coursier.fr) which is also not a shopify partner. 

Here is my need:

Create a checkout with storefront api > use the paygreen api to do the payment (via an iframe) > then, when the payment is successful (paygreen send the response to my server), mark the transaction and checkout as paid. I want to make a payment with PayGreen but keep the benefit of the shopify product management system. 

is it clear? Sorry my english is so bad 😂