Cloudhooks

Get notified when a refund is requested (Shopify)


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 = '[email protected]'
  const subject = `(${shopUrl}) Refund requested`
  const body = `<p>
    Please review the following refund: 
    <a href="${shopUrl}/admin/orders/${refund.order_id}">${refund.order_id}</a>
  </p>`

  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 })
  } 
}
  


Try Cloudhooks on your shop


.myshopify.com