Skip to content

Instantly share code, notes, and snippets.

@Pebblo Pebblo/functions.php
Last active Oct 17, 2018

Embed
What would you like to do?
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 ) {
$classes[] = 'event-id-' . $event->ID();
}
}
}
}
}
return $classes;
}
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
You can’t perform that action at this time.