Hi everyone,
I’m building a Checkout UI Extension using the purchase.checkout.block.render
target, and I want to access my app-owned metafields.
Here’s a simplified version of what I’m doing:
export default reactExtension('purchase.checkout.block.render', () => <Extension />);
function Extension() {
const metafields = useAppMetafields({
key: 'cc_pdp',
namespace: 'secret_keys',
type: 'string', // ← not sure if this is correct
});
console.log("Metafields:", metafields);
return (
<>
{metafields.map((entry, index) => (
<Text key={index}>
{entry.metafield.key}: {entry.metafield.value}
</Text>
))}
</>
);
}
My metafields are created through the app and are attached to app namespace resources.
But I’m not seeing any data in the console. I suspect the issue is with the ` ?
Same metafiled i have tested on the liquid it was print the data correct.
`
App Meta data ::
{{ app.metafields.secret_keys.cc_pdp }}
`
My Questions:
- What should the correct
type
be when accessing metafields saved on app own meta ? - Is
purchase.checkout.block.render
the right extension point to access App metafields value ? - Do I need to filter by key manually, or will
useAppMetafields
give me all metafields for items will be automatically ?
Any help or sample code would be appreciated!
Thanks