Create a product_reference metafield
Point a metafield at a product — send the numeric id, not a gid.
Send the plain numeric product id, not a gid:// string. FieldsRaven builds gid://shopify/Product/<id> itself before writing to Shopify. A full gid is rejected at validation with 422 Invalid product id — the value is checked with Integer(value), which a gid string fails, so it never reaches Shopify at all.
Before you start
Paste the raven's Get Code output into your theme first — that Liquid computes the signature and defines window.FR_<RESOURCE>_<KEY>. See Quick Start. The snippets below assume it is present, and use cfg for it.
Sending a value
async function submit(value) {
var cfg = window.FR_CUSTOMER_MY_KEY; // from the Get Code panel
var res = await fetch('/apps/raven/create_metafield', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
raven: {
raven_id: cfg.ravenId,
resource_id: cfg.resourceId,
raven_mac: cfg.ravenMac,
value: value
}
})
});
if (res.status === 429) return console.warn('Busy — retry shortly.');
var data = await res.json().catch(function () { return {}; });
if (!res.ok) return console.error(data.message || 'Rejected.');
console.log(data.message); // "Sit tight the raven is on it!"
}Last updated