Skip to content

Instantly share code, notes, and snippets.

@hadamlenz
Last active November 27, 2017 21:51
Show Gist options
  • Save hadamlenz/8095fba6c13c5c233518c8ce2105d841 to your computer and use it in GitHub Desktop.
Save hadamlenz/8095fba6c13c5c233518c8ce2105d841 to your computer and use it in GitHub Desktop.
Events Tickets Plus - Don't send tickets for specific events
<?php
function filter_send_tickets($send){
$dont_send_tickets = ["70"]; //the event IDs that you don't want to send tickets for
global $post;
$order = wc_get_order( $post->ID );
$items = $order->get_items();
$wootix = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
$events = [];
foreach( $items as $item ){
$event = $wootix->get_event_for_ticket( $item->get_product_id() );
if( !in_array($event->ID, $events) && NULL !== $event->ID ){
$events[] = $event->ID;
}
}
foreach( $events as $event ){
if( in_array( $event, $dont_send_tickets ) ) {
$send = 'no';
break;
}
}
return $send;
}
add_filter( 'wootickets-tickets-email-enabled', 'filter_send_tickets' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment