Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove the promotion input field for specific tickets
<?php //Please do not include the opening PHP tag if you already have one
function tw_remove_promo_input_for_specific_tkts( $before_payment_options) {
//If the promotions add-on is not active we don't need any of this to run.
if( class_exists('EEM_Promotion') ) {
$checkout = EE_Registry::instance()->SSN->checkout();
if ( $checkout instanceof EE_Checkout ) {
$transaction = $checkout->transaction;
if ( $transaction instanceof EE_Transaction ) {
//Create an array to hold the event ID's.
$TKT_IDs = array();
//Pull the Ticket ID's from the registrations.
foreach ( $transaction->registrations() as $registration ) {
if ( $registration instanceof EE_Registration ) {
$ticket = $registration->ticket();
$TKT_IDs[] = $ticket->ID();
}
}
//We only need each event ID once.
$TKT_IDs = array_unique($TKT_IDs);
// Set the ID's of the tickets that should remove the promotion field.
$no_promo_tkts = array( 25 );
if( array_intersect($TKT_IDs, $no_promo_tkts) ) {
//If any of the tickets in the cart martch the ID's set in $no_promo_tkts then remove the promo intput.
remove_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', array('EED_Promotions', 'add_promotions_form_inputs') );
}
}
}
}
return $before_payment_options;
}
add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options', 'tw_remove_promo_input_for_specific_tkts', 9 );
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.