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: Payment customization

Payment customization

rishika_286
Shopify Partner
11 0 0
Writed this query for get metafield from payment customization function 
query RunInput ($selectedCollectionIds: [ID!]) {
cart {
cost {
totalAmount {
amount
}
}
lines {
merchandise {
__typename
...on ProductVariant {
id
product {
id
handle
metafield(namespace: "payment-customization",
key: "function-configuration") {
value
}
hasTags(tags: []) {
tag
}
inAnyCollection(ids: $selectedCollectionIds)
}
}
}
}
}
paymentMethods {
id
name
}
paymentCustomization {
metafield(namespace: "payment-customization", key: "function-configuration") {
value
}
}
}

In Toml file write input variable this its working fine in app extension and also gives metafield but not working in frontend side.
[input.variables]
namespace = "payment-customization"
key = "function-configuration"
So, I corrected it by adding extensions before input.variable
[extensions.input.variables]
namespace = "payment-customization"
key = "function-configuration"
now its not working its giving metafiled null.
Please help me to solve this issue.
Thank you

Replies 7 (7)

Liam
Community Manager
3108 344 895

Hi Rishika_286,

 

There's a couple of things you can try to troubleshoot this issue:

  • Does the access token you are using on the frontend has the necessary permissions to access metafields?
  • Does your toml file match this structure?
  • Make sure that your frontend application is correctly passing the selectedCollectionIds variable to the query if it’s needed.

Try the above and let us know if you're still seeing issues. Hope this helps!

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

Nick_Wesselman
Shopify Staff
171 43 73

You posted this to another thread:

 

Nick_Wesselman_0-1698930026338.png

Your issue is unrelated to input query variables. The metafield on the product is either null, or its value exceeds the limit of 10KB.

Nick Wesselman | 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 the Shopify Help Center or the Shopify Blog

rishika_286
Shopify Partner
11 0 0

First of all - thanks for the answer!

I will carefully review the code according to your suggestion. Before that, could you please help me confirm one thing? I learned in the tutorial documentation(https://shopify.dev/docs/apps/functions/input-output/variables-queries) that Input query variables value can be set using the metafield collection on the create or update mutation on your function owner.

I am not getting how my metafield value is exceed limit if I only gives 3 values in it,
{
"selectedCollectionIds": [
"gid://shopify/Collection/1",
"gid://shopify/Collection/2",
"gid://shopify/Collection/3"
]
}

 

 

Nick_Wesselman
Shopify Staff
171 43 73

It sounds like you are setting the metafield on the wrong object. To use variables with a payment customization function, the metafield should be set on the payment customization itself. It appears you are already using that metafield for some function configuration. You can either add to that metafield, or specify a different one for your variables.

Nick Wesselman | 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 the Shopify Help Center or the Shopify Blog

rishika_286
Shopify Partner
11 0 0

Created different metafield in product for same but still its giving null value , can you please explain where I am doing wrong,
Screenshot from 2023-11-02 19-20-08.png

Nick_Wesselman
Shopify Staff
171 43 73

Don't put the metafield on the product. Put it on the payment customization.

Nick Wesselman | 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 the Shopify Help Center or the Shopify Blog

rishika_286
Shopify Partner
11 0 0

I have tried with this also still its giving null, defined metafield in admin product why it's giving null in payment-customization.
Is there any other approach to get metafield from the product.