|
|
|
|
|
|
|
|
|
zD8PU8blH4mfkpQ0
zD8PU8blH4mfkpQ0
|
|
Finish allocation guard and course exclusion presentation examples
Finish allocation guard and course exclusion presentation examples
|
|
<?php
$disabled = \Components\Marketing\Automation\Progress::getDisabledIds();
\Components\Marketing\Automation\Progress::setDisabledIds(array_column(\Components\Marketing\Automation::getAll(), 'automation_id'));
try {
foreach ([376, 377] as $courseId) \Components\AF\Courses::save(['course_id' => $courseId, 'course_type' => 'collective', 'course_total_hours' => 22]);
\Components\AF\Courses\Assignments\Submissions::save(['submission_id' => 15, 'submission_grade' => 80]);
\Components\Customers\Contacts::save(['contact_id' => 1394, 'contact_gael_nationality_id' => '34', 'contact_gael_country_of_birth_code' => '061']);
\Components\AF\Courses\PrivateCourses::configSaveValue('prevent_scheduling_beyond_paid_hours', 1);
$rows = \Components\Commerce\Discounts::getAll(['filter' => ['discount_title', '=', 'Course exclusion - Presentation Demo'], 'limit' => 1]);
$discountId = $rows ? reset($rows)['discount_id'] : \Components\Commerce\Discounts::save(['discount_title' => 'Course exclusion - Presentation Demo', 'discount_type' => 'percentage', 'discount_value' => 10, 'discount_scope' => 'product', 'discount_entity_type' => '\Components\AF\Courses', 'discount_excluded_product_entities' => [513], 'discount_code' => 'PRESENTATION10', 'discount_is_enabled_public' => 0, 'discount_is_enabled_admin' => 0]);
echo json_encode(['discount' => $discountId, 'private_guard' => \Components\AF\Courses\PrivateCourses::configGetValue('prevent_scheduling_beyond_paid_hours'), 'membership' => \Components\AF\Memberships::get(144), 'private_course' => \Components\AF\Courses::get(378)], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
} finally {
\Components\Marketing\Automation\Progress::setDisabledIds($disabled);
}
<?php
$disabled = \Components\Marketing\Automation\Progress::getDisabledIds();
\Components\Marketing\Automation\Progress::setDisabledIds(array_column(\Components\Marketing\Automation::getAll(), 'automation_id'));
try {
foreach ([376, 377] as $courseId) \Components\AF\Courses::save(['course_id' => $courseId, 'course_type' => 'collective', 'course_total_hours' => 22]);
\Components\AF\Courses\Assignments\Submissions::save(['submission_id' => 15, 'submission_grade' => 80]);
\Components\Customers\Contacts::save(['contact_id' => 1394, 'contact_gael_nationality_id' => '34', 'contact_gael_country_of_birth_code' => '061']);
\Components\AF\Courses\PrivateCourses::configSaveValue('prevent_scheduling_beyond_paid_hours', 1);
$rows = \Components\Commerce\Discounts::getAll(['filter' => ['discount_title', '=', 'Course exclusion - Presentation Demo'], 'limit' => 1]);
$discountId = $rows ? reset($rows)['discount_id'] : \Components\Commerce\Discounts::save(['discount_title' => 'Course exclusion - Presentation Demo', 'discount_type' => 'percentage', 'discount_value' => 10, 'discount_scope' => 'product', 'discount_entity_type' => '\Components\AF\Courses', 'discount_excluded_product_entities' => [513], 'discount_code' => 'PRESENTATION10', 'discount_is_enabled_public' => 0, 'discount_is_enabled_admin' => 0]);
echo json_encode(['discount' => $discountId, 'private_guard' => \Components\AF\Courses\PrivateCourses::configGetValue('prevent_scheduling_beyond_paid_hours'), 'membership' => \Components\AF\Memberships::get(144), 'private_course' => \Components\AF\Courses::get(378)], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
} finally {
\Components\Marketing\Automation\Progress::setDisabledIds($disabled);
}
|
|
|
|
2026-10-08 00:59:14
2026-10-08 00:59:14
|
|
|
|
Here's what this will do, in everyday terms:
**Before anything else:**
- It makes a note of which marketing automation messages are currently switched off, then temporarily switches off **all** of them. This means that while the script runs, no automated marketing messages (like emails or reminders) will be sent out. At the very end, it puts everything back exactly the way it was.
**Changes it makes:**
1. **Two courses** (numbered 376 and 377) will be changed so they are marked as "collective" type courses with a total of 22 hours each.
2. **One student submission** (number 15) will be given a grade of 80.
3. **One customer contact** (number 1394) will have their nationality and country of birth updated to specific Irish-language-related values.
4. **A setting for private courses** will be turned on, which stops people from booking private lessons beyond the hours they've already paid for.
**A discount it creates or finds:**
5. It looks for a discount called "Course exclusion - Presentation Demo". If it doesn't exist yet, it creates one: a 10% discount tied to a specific course, with the code PRESENTATION10. It's set up so it can't actually be used by customers or staff right now (it's switched off on both sides).
**At the end:**
- It shows some information on screen (the discount, the private-course setting, one membership, and one course) — this is just a display, not a change.
- All the marketing automations that were switched off at the start are switched back on again.
**In short:** it updates 2 courses, 1 grade, 1 contact's details, turns on one booking rule, and makes sure one discount exists — all while pausing automated marketing messages for the few seconds it runs.
Here's what this will do, in everyday terms:
**Before anything else:**
- It makes a note of which marketing automation messages are currently switched off, then temporarily switches off **all** of them. This means that while the script runs, no automated marketing messages (like emails or reminders) will be sent out. At the very end, it puts everything back exactly the way it was.
**Changes it makes:**
1. **Two courses** (numbered 376 and 377) will be changed so they are marked as "collective" type courses with a total of 22 hours each.
2. **One student submission** (number 15) will be given a grade of 80.
3. **One customer contact** (number 1394) will have their nationality and country of birth updated to specific Irish-language-related values.
4. **A setting for private courses** will be turned on, which stops people from booking private lessons beyond the hours they've already paid for.
**A discount it creates or finds:**
5. It looks for a discount called "Course exclusion - Presentation Demo". If it doesn't exist yet, it creates one: a 10% discount tied to a specific course, with the code PRESENTATION10. It's set up so it can't actually be used by customers or staff right now (it's switched off on both sides).
**At the end:**
- It shows some information on screen (the discount, the private-course setting, one membership, and one course) — this is just a display, not a change.
- All the marketing automations that were switched off at the start are switched back on again.
**In short:** it updates 2 courses, 1 grade, 1 contact's details, turns on one booking rule, and makes sure one discount exists — all while pausing automated marketing messages for the few seconds it runs.
|
|
|
|
|