Reminder to thank big spenders

This hook automatically sends you an email notification when a customer makes a purchase above a specified threshold amount. It also tags these high-value customers in your Shopify store for easy identification and relationship building.

Prerequisites

  • A Shopify store with Cloudhooks installed
  • Email address where you want to receive notifications

Implementation

1) Set up trigger

In Cloudhooks dashboard, select "An order is created" as your trigger event.

2) Configure settings

Customize these settings in the hook code:

  • Purchase threshold amount: Set MINIMUM_PURCHASE = 100 to define the dollar amount that triggers notifications
  • Customer tagging: Set CUSTOMER_TAG = 'big-spender' to categorize your high-value customers
  • Notification email: Update REMINDER_EMAIL = 'your-email@example.com' to receive alerts

3) Implement the hook


const MINIMUM_PURCHASE = 100  // Purchase price in USD
const CUSTOMER_TAG = 'big-spender'
const REMINDER_EMAIL = 'john.doe@example.com'

module.exports = async function (payload, actions, context ) {
  const { shopifyDomain } = context
  const subject = `(${shopifyDomain}) Large order created`
  const body = `
    ${payload.customer.email} just made a large order of $${payload.total_price}. 
    Maybe you want to thank them personally? 
    Order: ${payload.order_number}
  `
  if (parseInt(payload.total_price) > MINIMUM_PURCHASE) {
    await actions.shopify.tagCustomer(payload.customer.id, CUSTOMER_TAG)
    await actions.email.send({ to: REMINDER_EMAIL, subject, body })
  }
}

Testing

Test your hook using Cloudhooks' test payload feature with a sample order that exceeds your minimum purchase amount.

Important: Because this hook tags Shopify customers based on the customer ID in the payload, your test payload must contain a real customer ID from your store. Using fictional customer IDs will cause the Shopify API to return an error during testing.

Verify that:

  • You receive the notification email
  • The customer is properly tagged in your Shopify admin

Additional Resources

For more Cloudhooks examples, visit our Gist page on Github.