Skip to content

Order Reminder Emails

Flow ID: SY-14 | Module(s): job, eshop | Complexity: Low Last Updated: 2026-04-04

Business Overview

The order reminder job sends follow-up emails to customers with unpaid or pending orders, encouraging them to complete their purchase. This is a thin orchestration job in the platform core -- the actual reminder logic is entirely client-specific, implemented by overriding order_model->sendOrderReminder() in client repositories.

What the job does:

  • Delegates entirely to order_model->sendOrderReminder()
  • The base Adv_order_model does NOT implement sendOrderReminder() -- it is a hook point for client customization
  • Each client defines their own query criteria, email content, and reminder timing

Business value: Recovers abandoned orders by nudging customers to complete payment, with fully customizable business rules per client.


Architecture

AdvSendOrderReminderMail (JobCommand)
  |
  +--> order_model::sendOrderReminder()    [client-defined method]
         |
         +--> query eligible orders        [client criteria]
         +--> adv_mailer::send()           [client template]

Job Classes

ClassFilePurpose
AdvSendOrderReminderMailecommercen/job/libraries/AdvSendOrderReminderMail.phpBase job -- thin delegate
SendOrderReminderMailapplication/modules/job/libraries/SendOrderReminderMail.phpClient-overridable subclass

Dependencies

ClassFileRole
Adv_order_modelecommercen/eshop/models/Adv_order_model.phpBase order model (no reminder method)
Order_modelapplication/modules/eshop/models/Order_model.phpClient override point
Adv_mailerapplication/models/Adv_mailer.phpEmail dispatch

Code Flow

1. Job Initialization

The constructor loads order_model and adv_mailer:

constructor:
  load eshop/order_model
  load adv_mailer

2. Execute Command

The entire executeCommand() is a single delegation:

php
$this->ci->order_model->sendOrderReminder();

3. Client Implementation (Expected Pattern)

Client repos typically implement sendOrderReminder() in their Order_model override with logic such as:

  1. Query eligible orders: Select orders where status = 'PENDING' and entry_datetime is older than N days
  2. Filter by payment method: Optionally restrict to specific payment methods (e.g., bank transfer orders waiting for payment)
  3. Send reminder email: Use adv_mailer->send() with a custom template
  4. Mark processed: Update a flag to prevent duplicate reminders

The specific criteria, timing, and email content vary entirely by client.


Data Model

Primary Table: shop_order

The reminder job works with the order table, but the specific columns used depend on the client implementation. Common columns involved:

ColumnTypeRole
idintPK
order_serialvarcharHuman-readable order number
statusvarcharOrder status (PENDING, PAID, etc.)
entry_datetimedatetimeWhen the order was placed
paywayvarcharPayment method identifier
customer_idintFK to customer

Configuration

Job Scheduling (application/config/jobs.php)

php
// ['command' => 'SendOrderReminderMail', 'schedule' => '0 19 * * *', 'graceTime' => 300, 'retryTimes' => 3],

Commented out by default (client opt-in). Default schedule when enabled: daily at 19:00.

Job Options

The job defines no options (getOptions() returns an empty array). Client overrides may add their own.


Client Extension Points

  1. Implement the reminder method (required): Override Order_model in application/modules/eshop/models/ and implement sendOrderReminder(). This is the primary extension point -- the base platform provides no default implementation.

  2. Override the job class: Create SendOrderReminderMail in application/modules/job/libraries/ extending AdvSendOrderReminderMail. Override executeCommand() to add pre/post processing or pass options.

  3. Custom email templates: Create client-specific reminder email templates in application/views/.

  4. Multiple reminder schedules: Register multiple job entries with different options to support multi-stage reminder sequences (e.g., 24h, 48h, 7 days).


Business Rules

RuleDescription
Client-specificNo default reminder logic exists in the platform; each client must implement sendOrderReminder()
Opt-in activationJob is commented out by default in jobs.php; must be explicitly enabled per client
No built-in deduplicationClient implementations must manage their own sent-tracking to prevent duplicate reminders
Mailer pre-loadedThe adv_mailer model is loaded by the job constructor so client code can use it directly