Automatic Order Creation

Hi Team,

I am developing a subscription app and need to implement automated order creation based on the billing cycles. Could you please advise on the best approach to achieve this? Do we need to set up a cron job for this functionality?

Thanks,
Jubin

1 Like

Use a scheduled job (cron) that runs daily:

// Pseudo-code approach
cron.schedule('0 2 * * *', async () => {
  // Run at 2 AM daily
  
  // 1. Query subscriptions due today
  const dueSubscriptions = await db.subscriptions.find({
    status: 'active',
    next_billing_date: today,
  });
  
  // 2. Create orders for each
  for (const sub of dueSubscriptions) {
    await createOrder(sub);
    
    // 3. Update next billing date
    sub.next_billing_date = calculateNextDate(
      sub.billing_cycle // monthly/yearly
    );
    await sub.save();
  }
});

Key points:

  • Yes, you need a cron job - runs daily checking for subscriptions due
  • Store next_billing_date on each subscription
  • Query only subscriptions due today (indexed for performance)
  • After creating order, immediately calculate and update the next billing date
  • Use a queue (like Bull/BullMQ) for processing if you have high volume

Alternative: Use a dedicated service like Stripe Billing or Chargebee to handle this automatically.

For subscription apps, Shopify doesn’t automatically create the recurring orders, your app has to handle that part. The usual approach is to store each subscription’s next billing date, then run a scheduled job that checks which subscriptions are due and creates the orders through the Admin API.

Most apps handle this with a cron job or scheduled worker, so yes, that’s the normal setup. Your job just needs to run daily or more often and trigger order creation for any subscription cycle that’s due.

This keeps the order generation reliable and fully under your app’s control.

Hi,

Hope this will help

Shopify doesn’t automatically create renewal orders for subscriptions just because a billing cycle exists. Your app has to trigger the renewal by creating a billing attempt on the subscription contract. When that billing attempt succeeds Shopify creates the order.

The usual pattern is to run a scheduled background job (cron, serverless scheduler, queue worker etc.):

  • Looks up all subscription contracts in your own DB where the next billing date or billingAttemptExpectedDate is due.

  • Calls subscriptionBillingAttemptCreate (or the billing-cycle API) with an idempotencyKey.

  • Updates your records based on whether the billing attempt succeeded or failed and sets the next billing date.

Hi @Jubins

Automated order bulk creationEnabled by a background jobYou are able to process your own job that checks active subscriptions and creates draft orders via Admin API. Derive cycles from stable billing information from your app, then push orders programmatically instead of waiting for Shopify schedulesThis makes the logic sane and predictable.

Yes, for automated order creation in a Shopify subscription app, a scheduled task (cron job) is the typical approach. Here’s a simple outline:

  1. Determine Billing Cycles – Keep track of each subscriber’s next billing date in your database.

  2. Use a Cron Job / Scheduler – Run a task daily (or hourly if needed) to:

    • Check which subscriptions are due for renewal.

    • Create orders via the Shopify Admin API (POST /admin/api/2025-10/orders.json).

  3. Handle Payments – If you’re processing payments outside Shopify, charge the customer first, then create the order.

  4. Error Handling – Log failures, retry if needed, and notify if an order fails to generate.

  5. Optional: Use Shopify Webhooks (e.g., orders/create) if you need to react to events rather than strictly scheduling.