Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active June 8, 2020 21:00
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/f4561461339c59411a849f93c91912a9 to your computer and use it in GitHub Desktop.
Save Pebblo/f4561461339c59411a849f93c91912a9 to your computer and use it in GitHub Desktop.
Example of how you can include the event ID's for the registrations you currently have in your session within the checkout page body classes.
<?php //Please do not include the opening PHP tag if you already have one
function tw_ee_return_event_id_on_spco_body_class( $classes ){
// get out if this isn't the reg checkout page
if ( ! class_exists('EE_Registry') || ! is_page( EE_Registry::instance()->CFG->core->reg_page_id ) ){
return $classes;
}
$events = array();
$checkout = EE_Registry::instance()->SSN->checkout();
if ( $checkout instanceof EE_Checkout ) {
$transaction = $checkout->transaction;
if ( $transaction instanceof EE_Transaction ) {
foreach ( $transaction->registrations() as $registration ) {
if ( $registration instanceof EE_Registration ) {
$event = $registration->event();
if ( $event instanceof EE_Event ) {
$events[] = 'event-id-' . $event->ID();
}
}
}
}
}
$events = array_unique($events);
return array_merge( $classes, $events );
}
add_filter( 'body_class', 'tw_ee_return_event_id_on_spco_body_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment