We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ORDERS_UPDATED: { deliveryMethod: DeliveryMethod.Http, callbackUrl: "/api/webhooks", callback: async (topic, shop, body, webhookId, apiVersion) => { console.log("Received ORDERS_UPDATED webhook"); try { let session = await shopify.sessionStorage.loadSession(shop); if (!session) { console.error(Failed to load session for shop: ${shop}`); return; } } catch (error) { console.error("Error loading session:", error); }
ORDERS_UPDATED: { deliveryMethod: DeliveryMethod.Http, callbackUrl: "/api/webhooks", callback: async (topic, shop, body, webhookId, apiVersion) => { console.log("Received ORDERS_UPDATED webhook"); try { let session = await shopify.sessionStorage.loadSession(shop); if (!session) { console.error(
let accessToken = session.accessToken; const payload = JSON.parse(body); if (payload.closed_at === null) { console.log("Order is not closed. Triggering flow..."); const url = `https://${shop}/admin/api/${apiVersion}/graphql.json`; // console.log(payload); const triggerFlow = async (id) => { console.log("Inside triggerFlow function. Order ID:", id); const query = ` mutation { flowTriggerReceive( body: "{ \\"trigger_id\\": \\"##########################\\", \\"properties\\": { \\"order_id\\": ${id} } }" ) { userErrors {field, message} } } `; const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/graphql", "X-Shopify-Access-Token": accessToken, }, body: JSON.stringify({ query }), }); const responseData = await response.json(); console.log(responseData); }; // Trigger the Shopify Flow triggerFlow(payload.id) .then(() => { console.log("Flow triggered successfully"); }) .catch((error) => { console.error("Error triggering flow:", error); }); } else { console.log("Order is closed. Not triggering flow."); } },
}, }; `
This part:
let session = await shopify.sessionStorage.loadSession(shop);
Does not work. I am using your template. From the readme.MD it reads:
The Node app template comes with the following out-of-the-box functionality:
OAuth: Installing the app and granting permissions
How can I get the, or if someone can point me in the right direction
"X-Shopify-Access-Token": accessToken,
Kind Regards,
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Issue summary
ORDERS_UPDATED: { deliveryMethod: DeliveryMethod.Http, callbackUrl: "/api/webhooks", callback: async (topic, shop, body, webhookId, apiVersion) => { console.log("Received ORDERS_UPDATED webhook"); try { let session = await shopify.sessionStorage.loadSession(shop); if (!session) { console.error(
Failed to load session for shop: ${shop}`);return;
}
} catch (error) {
console.error("Error loading session:", error);
}
},
};
`
This part:
let session = await shopify.sessionStorage.loadSession(shop);
Does not work. I am using your template. From the readme.MD it reads:
How can I get the, or if someone can point me in the right direction
"X-Shopify-Access-Token": accessToken,
Kind Regards,
The text was updated successfully, but these errors were encountered: