Skip to main content
Version: 0.1.x

Product recommendations

obsolete: check how this is referenced now

SALVO-TS supports Shopify's Product Recommendations API.

If you link to a recommended product, make sure you use the url attribute on the returned product - this will let Shopify track the conversion for reporting purposes.

Get recommendations

ts
const res = await recommendations.recommend({
productId: 1234567890, // required
limit: 10, // optional, max 10
});
// -> {
// products: [
// // List of Shopify product objects
// ]
// }
ts
const res = await recommendations.recommend({
productId: 1234567890, // required
limit: 10, // optional, max 10
});
// -> {
// products: [
// // List of Shopify product objects
// ]
// }

Get recommendations & add or replace a new section

Insert a new section:

ts
await recommendations.recommend({
productId: 1234567890, // required
limit: 10, // optional, max 10
section: {
id: 'product-recommendations',
after: 'header',
}
});
ts
await recommendations.recommend({
productId: 1234567890, // required
limit: 10, // optional, max 10
section: {
id: 'product-recommendations',
after: 'header',
}
});

Replace an existing section:

ts
await recommendations.recommend({
productId: 1234567890, // required
limit: 10, // optional, max 10
section: {
id: 'product-recommendations',
replace: 'product-recommendations',
}
});
ts
await recommendations.recommend({
productId: 1234567890, // required
limit: 10, // optional, max 10
section: {
id: 'product-recommendations',
replace: 'product-recommendations',
}
});

Render a section and get the raw section HTML:

ts
const sectionHtml = await recommendations.recommend({
productId: 1234567890, // required
limit: 10, // optional, max 10
section: {
id: 'product-recommendations',
raw: true
}
});
ts
const sectionHtml = await recommendations.recommend({
productId: 1234567890, // required
limit: 10, // optional, max 10
section: {
id: 'product-recommendations',
raw: true
}
});