Last active
June 8, 2020 21:00
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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