Pulling Product Metafield Data into an Experience
You can now access product metafields directly through the Visually SDK using the visually.sdk_api.getProductsMetafields method. This allows you to retrieve metafield values for specific products and use them in your experiences.
Method
visually.sdk_api.getProductsMetafields(handles: string[], metafields: MetafieldRequest[])
Interface
interface MetafieldRequest {
namespace: string;
keys: string[];
}
This method returns the products along with their metafields. If a metafield is not returned, it means it wasn’t synced.
Sync Metafields in Visually
Before you can retrieve a metafield via the SDK, it must be synced in Visually.
-
Open your Visually dashboard.
-
Go to Global Rules → Product Metafields section.
-
Click Add New Metafield.
-
Enter the metafield information exactly as it appears in Shopify:

-
Namespace:
custom -
Key:
size_and_height

-


Once metafields are synced, you can retrieve them using the SDK method.
Example
visually.sdk_api.getProductsMetafields(
["medium-soft-ruled-journal-charcoal"],
[
{
namespace: "jasper",
keys: ["FFSS", "FFSS_Discount"],
}
]
);
Tips for Avoiding Common Issues
-
Always enter namespace and key separately in Visually.
-
Make sure the metafield exists and is populated in Shopify.
-
Sync any new metafields before attempting to fetch them via the SDK.