|
|
|
|
|
|
|
Correct course discount type for screenshot
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
$before = \Components\Marketing\Automation\Progress::getDisabledIds();
\Components\Marketing\Automation\Progress::setDisabledIds(array_column(\Components\Marketing\Automation::getAll(), 'automation_id'));
try {
\Components\Commerce\Discounts::save([
'discount_id' => 26,
'discount_entity_type' => \Components\AF\Courses\CollectiveCourses::class,
'discount_excluded_product_entities' => [513]
]);
$d = \Components\Commerce\Discounts::get(26);
echo json_encode(array_intersect_key($d, array_flip(['discount_id', 'discount_entity_type', 'discount_excluded_product_entities', 'discount_is_enabled_admin', 'discount_is_enabled_public'])), JSON_PRETTY_PRINT);
} finally {
\Components\Marketing\Automation\Progress::setDisabledIds($before);
}
|
|
Here's what this will do, in everyday terms:
**1. Temporarily pause all automated marketing messages.**
Before anything else happens, the script stops every marketing automation in the system from running — so no automated emails or messages get sent out while the change is being made. This affects **every automation that exists**.
**2. Change one existing discount.**
It updates the discount with the number 26 (a discount attached to collective courses) so that **one specific course — the one numbered 513 — is excluded** from that discount. In other words, after this change, that particular course will no longer be covered by discount 26, while everything else stays as it was.
**3. Turn the marketing messages back on.**
Once the discount change is done (whether it worked or failed), all the automated marketing messages are switched back on exactly as they were before.
**4. Show a summary on screen.**
Finally, it prints out a short summary of the discount — its number, what it applies to, which course is now excluded, and whether it's switched on for staff and for customers. This is just a confirmation message; it doesn't change anything.
**In short:** it briefly pauses all automated marketing messages, removes course 513 from discount 26 so that course is no longer discounted, then turns the messages back on and shows you the updated discount details.
|
|
|