Hey @scole954387 ,
you basically have to put one const after the other.
/*Register webhook for uninstalled app */
const registrationUninstalled = await Shopify.Webhooks.Registry.register({
shop,
accessToken,
path: "/webhooks",
topic: "APP_UNINSTALLED",
webhookHandler: async (topic, shop, body) => {
console.log('App uninstalled');
const obj = JSON.parse(body);
console.log(obj);
delete ACTIVE_SHOPIFY_SHOPS[shop];
},
});
if (registrationUninstalled.success) {
console.log('Successfully registered uninstalled app webhook!');
} else {
console.log('Failed to register uninstalled app webhook', registrationUninstalled.result);
}
/* Register webhook for orders paid */
const registrationOrderPaid = await Shopify.Webhooks.Registry.register({
shop,
accessToken,
path: '/webhooks',
topic: 'ORDERS_PAID',
webhookHandler: (_topic, shop, body) => {
console.log('received order paid webhook: ');
const obj = JSON.parse(body);
},
});
if (registrationOrderPaid.success) {
console.log('Successfully registered Order Paid webhook!');
} else {
console.log('Failed to register Order Paid webhook', registrationOrderPaid.result);
}
/* Register webhook for cart create */
const registrationCartCreate = await Shopify.Webhooks.Registry.register({
shop,
accessToken,
path: '/webhooks',
topic: 'CARTS_CREATE',
webhookHandler: (_topic, shop, body) => {
console.log('received cart created webhook: ');
const obj = JSON.parse(body);
console.log(obj);
},
});
if (registrationCartCreate.success) {
console.log('Successfully registered cart create webhook!');
} else {
console.log('Failed to register cart create webhook', registrationCartCreate.result);
}
/* Register webhook for cart update*/
const registrationCartUpdate = await Shopify.Webhooks.Registry.register({
shop,
accessToken,
path: '/webhooks',
topic: 'CARTS_UPDATE',
webhookHandler: async (_topic, shop, body) => {
console.log('received cart update webhook: ');
const obj = JSON.parse(body);
console.log(obj);
},
});
if (registrationCartUpdate.success) {
console.log('Successfully registered cart update webhook!');
} else {
console.log('Failed to register cart update webhook', registrationCartUpdate.result);
}