Shopify Functions + useAppMetafields()

Shopify Functions + useAppMetafields()

LMiller
Shopify Partner
18 0 5

Hey everyone,

 

I am deep in the weeds of trying to get my developer app working for our store to be able to rename a payment method using Shopify Functions but set it to the metafield value of the customer's company. We are a B2B store so all customers are assigned to a company.  {{ customer.current_company.metafields.custom.cc_1.value }} is essentially the metafield I want to rename our first manual payment method to. Not looking for a step-by-step guide but just wanting to confirm it's even possible. I've seen other people accomplish displaying a customer metafield in a UI Extension but haven't seen evidence of a company metafield in a Shopify Function.

Reply 1 (1)

jafarhansla
Visitor
1 0 0

It’s currently not possible to directly access company metafields within Shopify Functions. Shopify Functions allow you to extend and customize Shopify's backend logic, but they have limitations on the data they can access, especially when it comes to customer and company-specific data.

However, you can achieve something similar by combining Shopify Functions with a Shopify App or a UI Extension that accesses the company metafield, and then use that data to dynamically rename the payment method in the checkout process.

In summary, while you can’t directly pull a company metafield into a Shopify Function, you could work around this limitation by using other parts of Shopify's API or custom apps to achieve the desired behavior.