– Add event name column to the event table and cart
A recipe for adding an “Event Name” column to the ticket-type table and cart — useful for multi-event sites where buyers might be looking at a mixed-event ticket list and the ticket-type name alone doesn’t say which event.
In case you want to add the event name column to the event table and cart you just have to add this into your functions.php file:
add_action( 'tc_event_col_title_before_ticket_title', 'tc_event_col_title_before_ticket_title_new' );
add_action( 'tc_event_col_value_before_ticket_type', 'tc_event_col_value_before_ticket_type_new', 10, 1 );
function tc_event_col_title_before_ticket_title_new() {?>
<th><?php _e( 'Event', 'mp' ); ?></th>
<?php
}
function tc_event_col_value_before_ticket_type_new( $ticket_type_id ) {
$event_id = get_post_meta($ticket_type_id, 'event_name', true);
$event = new TC_Event( $event_id ); ?>
<td><?php echo $event->details->post_title; ?></td>
<?php
}
add_action( 'tc_cart_col_title_before_ticket_type', 'tc_cart_col_title_before_ticket_type' );
function tc_cart_col_title_before_ticket_type() { ?>
<th><?php _e( 'Event', 'tc' ); ?></th>
<?php
}
add_action( 'tc_cart_col_value_before_ticket_type', 'tc_cart_col_value_before_ticket_type', 10, 1 );
function tc_cart_col_value_before_ticket_type( $ticket_type_id ) {
$ticket_type = new TC_Ticket( $ticket_type_id ); $event_id = $ticket_type->get_ticket_event();
$event = new TC_Event( $event_id ); ?> <td class="ticket-event"><?php echo $event->details->post_title; ?></td>
<?php }
add_filter( 'tc_cart_table_colspan', 'tc_cart_table_colspan' );
function tc_cart_table_colspan( $colspan ) {
return $colspan + 1;
}Related
Was this article helpful?
Yes — great. No or partially? Tell us what was missing — we read every message and use it to improve these docs.