|
|
|
|
|
|
|
Keep the assignment roster clear and prepare a separate trial conversion example
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
$disabled = \Components\Marketing\Automation\Progress::getDisabledIds();
\Components\Marketing\Automation\Progress::setDisabledIds(array_column(\Components\Marketing\Automation::getAll(), 'automation_id'));
try {
// Keep the Friday assignment roster simple; the Wednesday class illustrates a converted trial.
\Components\AF\Enrollments::save(['enrollment_id' => 367, 'course_id' => 377, 'enrollment_comment' => 'Presentation Demo - converted trial, retained for reporting']);
$rows = \Components\AF\Enrollments::getAll(['filter' => [['course_id','=',377], 'AND', ['contact_id','=',1394], 'AND', ['enrollment_type','=','standard']], 'limit' => 1]);
if (!$rows) \Components\AF\Enrollments::save(['course_id' => 377, 'contact_id' => 1394, 'enrollment_type' => 'standard', 'enrollment_created_datetime' => '2026-10-07 00:00:00', 'enrollment_comment' => 'Presentation Demo - enrolled after trial']);
$rows = \Components\AF\Enrollments::getAll(['filter' => ['course_id','IN',[376,377]]]);
$split = \Components\AF\Enrollments::summariseTrials($rows);
$out = [];
foreach ($split as $type => $records) $out[$type] = count($records);
echo json_encode($out, JSON_PRETTY_PRINT);
} finally {
\Components\Marketing\Automation\Progress::setDisabledIds($disabled);
}
|
|
Here's what this will do, in everyday terms:
**1. Temporarily pause all automated marketing messages.**
Before anything else, it stops every marketing automation in the system from running — so no automated emails or messages go out while the changes below are being made. When everything is finished, it turns them all back on exactly as they were.
**2. Update one existing course sign-up record.**
It changes the record for one person already signed up to course 377, adding a note saying this is a presentation demo of a converted trial, kept for reporting purposes.
**3. Add a new sign-up record if one doesn't already exist.**
It checks whether a particular person (contact 1394) is already signed up to course 377 as a regular (paying) student. If they aren't, it creates one new sign-up for them, dated 7 October 2026, with a note saying they enrolled after trying the course. If they already are signed up, nothing new is added.
**4. Show a quick count on screen.**
Finally, it looks at all sign-ups for courses 376 and 377 and displays a simple count of how many are trials versus regular sign-ups. This is just a summary shown on screen — it doesn't change anything.
**In short:** it pauses all marketing automations for a moment, updates one sign-up record, possibly adds one new sign-up record (at most one), then resumes the marketing automations and shows a count of trial versus regular students in two courses.
|
|
|