npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

shopify-order-alerts

v1.0.0

Published

A Node.js package for monitoring Shopify orders and sending email alerts

Downloads

8

Readme

// README.md

Shopify Order Alerts

A Node.js package for monitoring Shopify orders and sending email alerts. Perfect for managing multiple stores and getting real-time notifications about new orders, order status changes, and custom order criteria.

Features

  • Multi-store support: Manage multiple Shopify stores in one instance
  • API version validation: Ensures correct Shopify API version format
  • Email alerts: Send customized email notifications
  • Real-time monitoring: Continuous order monitoring with configurable intervals
  • Custom criteria: Filter orders by status, date, customer, and more
  • Error handling: Comprehensive error handling with detailed messages

Installation

npm install shopify-order-alerts

Quick Start

const ShopifyOrderAlerts = require('shopify-order-alerts');

// Initialize
const orderAlerts = new ShopifyOrderAlerts();

// Add store
orderAlerts.addStore('mystore', 'mystore.myshopify.com', 'your-access-token', '2023-10');

// Configure email
orderAlerts.setEmailConfig({
  host: 'smtp.gmail.com',
  port: 587,
  secure: false,
  auth: {
    user: '[email protected]',
    pass: 'your-app-password'
  },
  from: '[email protected]'
});

// Start monitoring
const monitor = orderAlerts.startOrderMonitoring('mystore', ['[email protected]'], 15);

API Reference

Constructor

const orderAlerts = new ShopifyOrderAlerts();

Store Management

addStore(storeName, shopDomain, accessToken, apiVersion)

Add a new Shopify store configuration.

  • storeName (string): Unique identifier for the store
  • shopDomain (string): Shopify domain (e.g., 'mystore.myshopify.com')
  • accessToken (string): Shopify Admin API access token
  • apiVersion (string): API version in YYYY-MM format (e.g., '2023-10')
orderAlerts.addStore('store1', 'store1.myshopify.com', 'shpat_xxxxx', '2023-10');

getStoreInfo(storeName)

Get store configuration details.

const storeInfo = orderAlerts.getStoreInfo('store1');

getStoreNames()

Get all configured store names.

const stores = orderAlerts.getStoreNames();

Email Configuration

setEmailConfig(emailConfig)

Configure email settings for sending alerts.

orderAlerts.setEmailConfig({
  host: 'smtp.gmail.com',
  port: 587,
  secure: false,
  auth: {
    user: '[email protected]',
    pass: 'your-app-password'
  },
  from: '[email protected]'
});

testEmailConfig()

Test email configuration.

const result = await orderAlerts.testEmailConfig();

Order Retrieval

getOrders(storeName, params)

Get orders with optional parameters.

const orders = await orderAlerts.getOrders('store1', {
  status: 'open',
  limit: 50
});

getRecentOrders(storeName, hours)

Get recent orders (default: last 24 hours).

const recentOrders = await orderAlerts.getRecentOrders('store1', 12);

getOrdersByStatus(storeName, status, limit)

Get orders by status.

const openOrders = await orderAlerts.getOrdersByStatus('store1', 'open', 100);

Email Alerts

sendEmailAlert(recipients, subject, htmlContent, textContent)

Send custom email alert.

await orderAlerts.sendEmailAlert(
  ['[email protected]', '[email protected]'],
  'Custom Alert',
  '<h1>Alert Message</h1>',
  'Alert Message'
);

sendNewOrderAlert(storeName, recipients, orders)

Send new order notification.

await orderAlerts.sendNewOrderAlert('store1', ['[email protected]'], orders);

sendCustomOrderAlert(storeName, recipients, criteria, alertTitle)

Send alert based on custom criteria.

await orderAlerts.sendCustomOrderAlert(
  'store1',
  ['[email protected]'],
  { status: 'open', financial_status: 'paid' },
  'Paid Orders Alert'
);

Monitoring

startOrderMonitoring(storeName, recipients, checkInterval)

Start continuous order monitoring.

const monitor = orderAlerts.startOrderMonitoring('store1', ['[email protected]'], 10);

// Stop monitoring
monitor.stop();

// Get status
const status = monitor.getStatus();

Examples

Basic Usage

const ShopifyOrderAlerts = require('shopify-order-alerts');

async function basicExample() {
  const orderAlerts = new ShopifyOrderAlerts();

  // Add store
  orderAlerts.addStore('mystore', 'mystore.myshopify.com', 'shpat_xxxxx', '2023-10');

  // Configure email
  orderAlerts.setEmailConfig({
    host: 'smtp.gmail.com',
    port: 587,
    secure: false,
    auth: {
      user: '[email protected]',
      pass: 'app-password'
    },
    from: '[email protected]'
  });

  // Get recent orders
  const recentOrders = await orderAlerts.getRecentOrders('mystore');
  console.log(`Found ${recentOrders.orders.length} recent orders`);

  // Send alert for new orders
  if (recentOrders.orders.length > 0) {
    await orderAlerts.sendNewOrderAlert('mystore', ['[email protected]'], recentOrders.orders);
  }
}

Multi-Store Monitoring

async function multiStoreExample() {
  const orderAlerts = new ShopifyOrderAlerts();

  // Add multiple stores
  orderAlerts.addStore('store1', 'store1.myshopify.com', 'token1', '2023-10');
  orderAlerts.addStore('store2', 'store2.myshopify.com', 'token2', '2024-01');

  // Configure email once
  orderAlerts.setEmailConfig({
    host: 'smtp.gmail.com',
    port: 587,
    secure: false,
    auth: {
      user: '[email protected]',
      pass: 'app-password'
    },
    from: '[email protected]'
  });

  // Monitor all stores
  const monitors = [];
  for (const storeName of orderAlerts.getStoreNames()) {
    const monitor = orderAlerts.startOrderMonitoring(storeName, ['[email protected]'], 15);
    monitors.push(monitor);
  }

  // Stop all monitors after 1 hour
  setTimeout(() => {
    monitors.forEach(monitor => monitor.stop());
  }, 60 * 60 * 1000);
}

Custom Alert Criteria

async function customAlertExample() {
  const orderAlerts = new ShopifyOrderAlerts();

  // Setup (store and email config)
  orderAlerts.addStore('mystore', 'mystore.myshopify.com', 'token', '2023-10');
  orderAlerts.setEmailConfig({ /* email config */ });

  // Alert for high-value orders
  await orderAlerts.sendCustomOrderAlert(
    'mystore',
    ['[email protected]'],
    { 
      status: 'open',
      financial_status: 'paid'
    },
    'High Priority Orders'
  );

  // Alert for orders needing fulfillment
  await orderAlerts.sendCustomOrderAlert(
    'mystore',
    ['[email protected]'],
    { 
      status: 'open',
      fulfillment_status: 'unfulfilled'
    },
    'Orders Ready for Fulfillment'
  );
}

Error Handling

The package provides comprehensive error handling:

try {
  // Invalid API version
  orderAlerts.addStore('store1', 'store1.myshopify.com', 'token', '2023-1'); // Will throw error
} catch (error) {
  console.error('API Version Error:', error.message);
}

try {
  // Store not found
  const orders = await orderAlerts.getOrders('nonexistent-store');
} catch (error) {
  console.error('Store Error:', error.message);
}

try {
  // Email configuration issues
  await orderAlerts.sendEmailAlert(['invalid-email'], 'Test', 'Content');
} catch (error) {
  console.error('Email Error:', error.message);
}

Requirements

  • Node.js >= 14.0.0
  • Valid Shopify Admin API access token
  • SMTP email server credentials

License

MIT