For discussing the development and usage of Checkout UI extensions, post-purchase extensions, web pixels, Customer Accounts UI extensions, and POS UI extensions
But if there are 10 line items, this requires 10 storefront API calls.
Is there any better way?
Any update on this? I got the same question
I also came here to find the answer! Any updates Shopify?
EDIT: I found a suggestion in github:
In addition to using the storefront API, you can use the "app metafields" API. With this API, you list the metafields you want as a metafields key in your shopify.extension.toml, and those metafields are queried on a number of objects in checkout, including the products and variants in cart lines. The useAppMetafields() hook lets you look these metafields up based on the results you get from the cart lines:
import {useCartLines, useAppMetafields} from '@shopify/checkout-ui-extensions-react';
function MyExtension() {
const firstLine = useCartLines()[0];
const variantMetafields = useAppMetafields({id: firstLine.merchandise.id});
const productMetafields = useAppMetafields({id: firstLine.merchandise.product.id});
}
Having same problem to get product metafields in webPixel extension
probably related to
https://community.shopify.com/c/extensions/using-storefront-api-in-custom-web-pixel/td-p/2531794