This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Environment variables to configure: | |
* - API_URL: URL of the Product Classifier API | |
* - API_KEY: API KEY generated in Product Classifier | |
* - CATEGORIZATION_TAG: The tag added to the categorized product to prevent infinite "Product updated" loops | |
* - CUSTOM_INSTRUCTIONS: Any instructions to the AI how to categorize products (optional) | |
*/ | |
module.exports = async function(payload, actions, context) { | |
const PRODUCT_CLASSIFIER_API_KEY = context.env.API_KEY; | |
const PRODUCT_CLASSIFIER_API_URL = context.env.API_URL; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findCartAttribute(payload, attributeName) { | |
let result = null; | |
if (payload.note_attributes && payload.note_attributes.length > 0) { | |
payload.note_attributes.every( attrib => { | |
if (attrib.name === attributeName) { | |
result = attrib.value; | |
return false; | |
} | |
return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async (refund, actions, { shopUrl }) => { | |
// Adjust these variables to customize | |
const refundMinimum = 0 | |
const to = '[Your email address]' | |
const subject = `(${shopUrl}) Refund requested` | |
const body = ` | |
Please review the following refund: | |
${refund.order_id} | |
` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async (order, actions, { shopifyDomain }) => { | |
// Adjust these variables to customize | |
const minimumPurchase = 100 // in dollars | |
const tag = 'big-spender' | |
const to = '[email protected]' | |
const subject = `(${shopifyDomain}) Large order created` | |
const body = ` | |
${order.customer.email} just made a large order of $${order.total_price}. | |
Maybe you want to thank them personally? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const apiKey = 'Your Mailerlite API key'; | |
const subscriberGroups = ['Subscriber group id1', 'Subscriber group id2']; | |
module.exports = async function(payload, actions) { | |
const httpConfig = { | |
headers: { | |
'Authorization': `Bearer ${apiKey}` | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const API_SECRET = '[Your GA4 API secret]'; | |
const MEASUREMENT_ID = '[Your GA4 measurement id]'; | |
module.exports = async function(payload, actions, context) { | |
const gaUrl = 'https://www.google-analytics.com/mp/collect' + | |
`?api_secret=${API_SECRET}` + | |
`&measurement_id=${MEASUREMENT_ID}`; | |
const gaData = { |