How to get the data from the metafields inside Post purchase extension

Hello. I’m working on the post purchase extensions for shopify, and I need to access the product level metafield (metafield type = variant) from my extension, for some reason the array of metafields inside const inputData = useExtensionInput(); is empty.

Here’s the output of inputData from the post purchase extension
{
“locale”: “en-US”,
“inputData”: {
“token”: “...”,
“shop”: {
“id”: 71985168561,
“domain”: “...”,
“metafields”:
},
“initialPurchase”: {
“referenceId”: “e1f6e34de4677085d0db57eae3917ffd”,
“customerId”: 8524178882737,
“destinationCountryCode”: “US”,
“totalPriceSet”: {
“shopMoney”: {
“amount”: “949.95”,
“currencyCode”: “USD”
},
“presentmentMoney”: {
“amount”: “949.95”,
“currencyCode”: “USD”
}
},
“lineItems”: [
{
“totalPriceSet”: {
“shopMoney”: {
“amount”: “949.95”,
“currencyCode”: “USD”
},
“presentmentMoney”: {
“amount”: “949.95”,
“currencyCode”: “USD”
}
},
“quantity”: 1,
“product”: {
“id”: 8823256121521,
“title”: “_The Inventory Not Tracked Snowboard”,
“variant”: {
“id”: 46271071617201,
“title”: “Default Title”,
“metafields”: <--------------------- ???
},
“metafields”:
},
“sellingPlanId”: null
}
]
},
“locale”: “en-US”,
“extensionPoint”: “Checkout::PostPurchase::Render”,
“version”: “unstable”
},
“extensionPoint”: “Checkout::PostPurchase::Render”,
“version”: “unstable”,
“storage”: {
“initialData”: {
“initialState”: {
“couldBe”: “anything”
}
}
}
}

Here’s my metafields definition from shopify.extension.toml file:

[[metafields]]
namespace = “custom”
key = “suggested_product”
resource = “product”

Questions:
Does your product have this metafield? => Yes
Does your metafield have storefront api access? => Yes
Did you redeploy the app when you changed the shopify.extension.toml? => Yes

Hi @ivan_levchenko

Are you currently making a separate API call (either to the Storefront API or your own backend) to fetch the product metafield after the extension renders?

Hello, thank you for your response. No, I don’t do that. If I should fetch the metafields, what is the purpose of [[metafields]] properties in the toml file then? I can fetch them without specifying any metafields in my extension config. Is it the only way?