August 3rd, 2022
When setting a metafield to a type “product” you would be forgiven for thinking it would return a product object when accessed.
Unfortunately, this is Shopify so it returns a String GID.
It took me a lot longer than I would like to admit to figure this out. It was the reason I couldn’t access any of the product’s variables.
To access the object simply replace:
or use the .value object on it:
Appending .value loads the object rather than returning shopify’s gid:// string.
Alternatively we can use the all_products array to access the products by GID.