Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created January 29, 2021 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/77a237e8ce3b3e3aad21d157f69ff2dd to your computer and use it in GitHub Desktop.
Save Pebblo/77a237e8ce3b3e3aad21d157f69ff2dd to your computer and use it in GitHub Desktop.
Example of how to trigger messages to send when a user 'revisits' spco and updates their registration.
<?php // Please doe no include the opening PHP tag if you already have one.
add_action(
'AHEE__EE_Single_Page_Checkout__process_attendee_information__end',
'tw_ee_trigger_messages_on_revisit',
10,
2
);
function tw_ee_trigger_messages_on_revisit($spco, $valid_data) {
if ($spco->checkout->revisit) {
$transaction = $spco->checkout->transaction;
// No transaction? Get outta here.
if(! $transaction instanceof EE_Transaction ) {
return
}
$trigger_notifications = true;
// now update the registrations and add the results to our $update_params
if ($trigger_notifications) {
// Add filter to send messages.
add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 15);
// The function used to sned message checks for values on the request, include those to force it to send.
$update_params = array(
'finalized' => true,
'revisit' => $spco->checkout->revisit,
'status_updates' => true,
);
// send messages
/** @type EE_Registration_Processor $registration_processor */
$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
$registration_processor->trigger_registration_update_notifications(
$transaction->primary_registration(),
$update_params
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment