const { auths, libs } = require('platform');
module.exports = async (event, options) => {
const shopify = libs.shopify.get();
const db = libs.shypyard.get().db();
// get full product detail
const product = await shopify.product.get(event.data.id);
const key = `old-product-description:${product.id}`;
if (product.inventory == 0) {
// when product is out of stock, change description and
await db.set(key, { val: product.description_html });
await shopify.product.update(
{ description_html: '....some new description' },
// restore old description
const {val: oldVal} = await db.get(key);
await shopify.product.update(
{ description_html: oldVal },