Skip to content

Instantly share code, notes, and snippets.

@cloudhooks
Created December 14, 2023 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudhooks/73bc78ea20153fd70454f8057db4755a to your computer and use it in GitHub Desktop.
Save cloudhooks/73bc78ea20153fd70454f8057db4755a to your computer and use it in GitHub Desktop.
Use this hook to find out when some customer support is needed.
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}
`
const totalRefundAmount = refund.refund_line_items.reduce((total, item) => {
return total + parseInt(item.subtotal)
}, 0)
if (totalRefundAmount > refundMinimum) {
await actions.email.send({ to, subject, body })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment