-
-
Save Pebblo/ff10c717dbef698ff7fbe357dedfd1a1 to your computer and use it in GitHub Desktop.
Add event's category slug to registration checkout and thank you page's body class
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 add the opening PHP tag if you already have one | |
// add category slug to registration checkout and thank you page's body class | |
add_filter( 'body_class', 'jf_ee_return_event_tax_term_on_spco' ); | |
function jf_ee_return_event_tax_term_on_spco( $classes ){ | |
// get out if this isn't the reg checkout page | |
if (! is_page( 'thank-you' ) && ! is_page( 'registration-checkout' ) ){ | |
return $classes; | |
} | |
//No transaction to begin with. | |
$transaction = NULL; | |
//If on the checkout page use the checkout SSN | |
if ( is_page( 'registration-checkout') ) { | |
$checkout = EE_Registry::instance()->SSN->checkout(); | |
if ( $checkout instanceof EE_Checkout ) { | |
$transaction = $checkout->transaction; | |
} | |
} | |
//If on the thank you page use the query string and pull the transaction | |
if ( is_page( 'thank-you' ) ) { | |
$transaction = EE_Registry::instance()->load_model( 'Transaction' )->get_transaction_from_reg_url_link(); | |
} | |
//Check we have a transaction before we do anything else | |
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; | |
$category = $event->first_event_category(); | |
if ( $category instanceof EE_Term ) { | |
$category_slug = $category->slug(); | |
$classes[] = $category_slug; | |
} | |
} | |
} | |
} | |
} | |
return $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 add the opening PHP tag if you already have one | |
// add category slug to registration checkout and thank you page's body class | |
add_filter( 'body_class', 'jf_ee_return_event_tax_term_on_spco' ); | |
function jf_ee_return_event_tax_term_on_spco( $classes ){ | |
// get out if this isn't the reg checkout page | |
if (! is_page( 'thank-you' ) && ! is_page( 'registration-checkout' ) && ! is_page('registration-cancelled') ){ | |
return $classes; | |
} | |
//No transaction to begin with. | |
$transaction = NULL; | |
//If on the checkout page use the checkout SSN | |
if ( is_page( 'registration-checkout') || is_page('registration-cancelled') ) { | |
$checkout = EE_Registry::instance()->SSN->checkout(); | |
if ( $checkout instanceof EE_Checkout ) { | |
$transaction = $checkout->transaction; | |
} | |
} | |
//If on the thank you page use the query string and pull the transaction | |
if ( is_page( 'thank-you' ) ) { | |
$transaction = EE_Registry::instance()->load_model( 'Transaction' )->get_transaction_from_reg_url_link(); | |
} | |
//Check we have a transaction before we do anything else | |
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; | |
$category = $event->first_event_category(); | |
if ( $category instanceof EE_Term ) { | |
$category_slug = $category->slug(); | |
$classes[] = $category_slug; | |
} | |
} | |
} | |
} | |
} | |
return $classes; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment