Appearance
Review Reminder Emails
Flow ID: SY-11 | Module(s): job, eshop | Complexity: Medium
Business Overview
The review reminder system sends automated emails to customers prompting them to leave reviews on Google, Facebook, or Skroutz after their orders are delivered. Each platform has its own query logic targeting different customer segments (e.g., Skroutz reviews only target Skroutz-referred orders). The job tracks sent reminders in a dedicated table to prevent duplicate emails, and a permission check ensures each customer receives at most one review request per platform.
Architecture
AdvSendMailToCustomersForReview (job)
(requires reviewKey option)
|
v
order_model::sendMailForReviewToCustomers($reviewKey)
|
+--- reviewForGoogle ---> getMailsForGoogleReview()
| (4-day delivery window, gtflag check)
|
+--- reviewForFacebook -> getMailsForFacebookReview()
| (order date + delivery confirmation)
|
+--- reviewForSkroutz --> getMailsForSkroutzReview()
(skroutz_referer=1 + delivery)
|
v
For each eligible customer:
allowSendEmailForReview() check
|
v
adv_mailer::sendCustomerPromptReview()
|
v
INSERT into shop_customer_reviews (tracking)Key Components
| Component | Path | Role |
|---|---|---|
AdvSendMailToCustomersForReview | ecommercen/job/libraries/AdvSendMailToCustomersForReview.php | Job: dispatches review reminder flow |
Adv_order_model | ecommercen/eshop/models/Adv_order_model.php | Model: platform-specific eligible customer queries |
Adv_mailer | application/models/Adv_mailer.php | Mailer: sends templated review request emails |
allowSendEmailForReview() | ecommercen/helpers/shopmodule_helper.php | Helper: duplicate prevention check |
| Review config | application/config/app.php | Review platform definitions (IDs and subject keys) |
| Client stub | application/modules/job/libraries/SendMailToCustomersForReview.php | Empty extension point |
Code Flow
Job Execution
- Entry:
executeCommand(['reviewKey' => $key])wherereviewKeyis one ofreviewForGoogle,reviewForFacebook, orreviewForSkroutz. - Model dispatch: Calls
order_model->sendMailForReviewToCustomers($reviewKey). - Platform routing: A
switchonreviewKeycalls the appropriate query method. If no valid key is provided,exit(0)terminates immediately. - Per-customer loop: For each eligible customer record:
- Duplicate check:
allowSendEmailForReview($email, $actionId)queriesshop_customer_reviewsfor an existing record with the same email and action ID. Returnstrueonly if no prior record exists. - Email send:
adv_mailer->sendCustomerPromptReview($customer, $reviewKey)sends the templated email. Subject line is resolved from registry (EMAIL_SUBJECTSgroup) per platform. - Tracking insert: Records
{mail, entry_date, action_id}inshop_customer_reviews.
- Duplicate check:
Platform-Specific Queries
Google Reviews (getMailsForGoogleReview)
- Date window: Yesterday's deliveries (
gtdatetimewithin previous day's 00:00-23:59). - Delivery span filter: Uses
DATEDIFF(gtdatetime, entry_datetime) = 4to target orders delivered exactly 4 days after placement. - Conditions:
gtflag = 1(delivery confirmed), email not matching the invalid email pattern. - Returns:
id,mail,langper customer (DISTINCT).
Facebook Reviews (getMailsForFacebookReview)
- Order date: 5 days ago (yesterday minus 4 days).
- Delivery date: Yesterday or later.
- Conditions:
gtflag = 1, status IN (INVOICED,SENT,PAID_SENT), email not matching invalid pattern. - Returns:
id,mail,langper customer (DISTINCT).
Skroutz Reviews (getMailsForSkroutzReview)
- Same logic as Facebook with additional filter:
skroutz_referer = 1(order originated from Skroutz marketplace). - Returns:
id,mail,langper customer (DISTINCT).
Data Model
Tables
| Table | Relevant Columns | Role |
|---|---|---|
shop_order | customer_id, entry_datetime, gtflag, gtdatetime, status, skroutz_referer | Order records with delivery tracking data |
shop_customer | id, mail, lang | Customer contact info and language preference |
shop_customer_reviews | mail, entry_date, action_id | Tracks which review emails have been sent |
Review Action IDs
| Platform | action_id | Config Key |
|---|---|---|
| 1 | reviewForFacebook | |
| Skroutz | 2 | reviewForSkroutz |
| 3 | reviewForGoogle |
Key Fields
| Field | Table | Description |
|---|---|---|
gtflag | shop_order | Boolean: courier delivery confirmed |
gtdatetime | shop_order | Timestamp of courier delivery confirmation |
skroutz_referer | shop_order | Boolean/int: order originated from Skroutz marketplace |
entry_datetime | shop_order | Order placement timestamp |
Configuration
Application Config: application/config/app.php
php
$config['reviews'] = [
'reviewForFacebook' => ['id' => 1, 'subject' => 'site.emails.prompt_review.facebook'],
'reviewForSkroutz' => ['id' => 2, 'subject' => 'site.emails.prompt_review.skroutz'],
'reviewForGoogle' => ['id' => 3, 'subject' => 'site.emails.prompt_review.google'],
];Registry Settings (Email Subjects)
| Group | Key | Description |
|---|---|---|
EMAIL_SUBJECTS | REVIEW_FOR_FACEBOOK | Localized email subject for Facebook review |
EMAIL_SUBJECTS | REVIEW_FOR_SKROUTZ | Localized email subject for Skroutz review |
EMAIL_SUBJECTS | REVIEW_FOR_GOOGLE | Localized email subject for Google review |
Email Templates
| reviewKey | Template View |
|---|---|
reviewForFacebook | reviewForFacebook (via emailViews->layoutView()) |
reviewForSkroutz | reviewForSkroutz |
reviewForGoogle | reviewForGoogle |
Job Options
| Job | Option | Type | Required | Description |
|---|---|---|---|---|
AdvSendMailToCustomersForReview | reviewKey | string | Yes (effectively) | Platform: reviewForGoogle, reviewForFacebook, or reviewForSkroutz |
Note: The job is typically scheduled three times in the cron -- once per platform -- each with a different reviewKey value.
Client Extension Points
- Job override: Create
SendMailToCustomersForReviewinapplication/modules/job/libraries/extending theAdv*base to add custom review platforms or modify query logic. - Order model override: Override the
getMailsFor*Review()methods inapplication/models/to change delivery window, status filters, or add custom conditions. - Mailer override: Override
sendCustomerPromptReview()inAdv_mailerto customize email content or add platform-specific tracking parameters. - Review config: Add new entries to
$config['reviews']inapplication/config/app.phpfor additional review platforms.
Business Rules
- One email per platform per customer: The
allowSendEmailForReview()check ensures a customer never receives more than one review request per platform (lifetime, not per order). - 4-day delivery window: Google reviews specifically target orders delivered exactly 4 days after placement (
DATEDIFF = 4), ensuring the customer has had time to evaluate the product. - Delivery confirmation required: All platforms require
gtflag = 1(courier delivery confirmed) before sending. - Invalid email exclusion: Sanitized customers (with UUID-based invalid emails) are automatically excluded via the
NOT LIKEfilter on the invalid email domain. - Skroutz exclusivity: Skroutz review reminders only target orders that originated from the Skroutz marketplace (
skroutz_referer = 1). - Language awareness: The customer's
langfield is included in query results, enabling the mailer to send localized emails. - No feature toggle: Unlike other email jobs, review reminders have no registry-based enable/disable flag. Scheduling or unscheduling the cron job is the on/off mechanism.
- Exit on invalid key: If an invalid or missing
reviewKeyis provided, the flow callsexit(0)rather than throwing an exception.
Related Flows
- SY-01 Cron Framework -- Job registration and scheduling infrastructure
- SY-24 Email Dispatch System --
Adv_mailerinternals, SMTP routing, and template rendering used bysendCustomerPromptReview() - CF-16 Product Reviews -- Customer-facing review submission and display
- SY-02 Order Status Emails -- Other order-related email automation
- SY-09 Customer Data Jobs -- GDPR sanitization deletes review tracking records
- AD-52 Review Moderation -- admin-side review approval and moderation