In the process of developing your site you may find that you only have access to a product's Shopify ID, but you'd like to find the product in Nacelle. In these instances you'll need to first convert the Shopify ID into a nacelleEntryId, and then query the Nacelle SDK or API using the nacelleEntryId.
Here's a function that will convert a Shopify ID into a nacelleEntryID:
function shopifyIdToNacelleEntryId(shopifySubdomain, shopifyId) {
const base64Encode = (x) =>
typeof document !== "undefined"
? globalThis.btoa(x)
: Buffer.from(x).toString("base64");
const nacelleEntryId = base64Encode(
`id://SHOPIFY/${shopifySubdomain}/default/PRODUCT/${shopifyId}/en-US`
);
console.log(nacelleEntryId);
}
Comments
0 comments
Please sign in to leave a comment.