Use this hook to find out when some customer support is needed! This is a great opportunity to reach out and change an unhappy customer to a loyal one.
The refundMinimum variable is useful for setting a dollar amount, over which, you want to be notified for a given refund. Default is $0, so you will receive an email for every refund.
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 })
}
}
For more examples, you can visit our Gist page on Github.