This can be done by relocating one of the templates and making a change to some lines of code. This will ensure that your customization is not lost on a software update.
The support team at Event Espresso will never recommend you edit any core plugin or add-on files directly.
Here are the steps:
-
Login to your WordPress root with your preferred SFTP or FTP client. Filezilla and Cyberduck are free options. On a Mac? Try Transmit
-
Browse to this location:
/wp-content/plugins/eea-events-table-view-template/templates
You'll see two files there:
espresso-events-table-template-toggle.template.php
espresso-events-table-template.template.php
-
Download a copy of the
espresso-events-table-template.template.php
file to your computer -
Now browse to your child theme:
/wp-content/themes/name-of-your-child-theme
Not using a child theme? A child theme allows you to customize your WordPress theme without losing customizations when you update your theme through WP. Here is how to setup a child theme.
-
Upload the the file that you downloaded earlier to the location above
-
Open the espresso-events-table-template.template.php file for editing
At about line 46 you'll see this line of code:
<th class="th-group"><?php _e('Date','event_espresso'); ?></th>
- Replace the line above with this:
<th class="th-group"><?php _e('Date','event_espresso'); ?></th>
<th class="th-group"><?php _e('Starting From','event_espresso'); ?></th>
- At about line 53, you'll see this line of code:
<td colspan="4">
- Replace it with this:
<td colspan="5">
- At about line 99 you'll see this line of code:
$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 );
$datetime = end( $datetimes );
- Replace it with this:
$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 );
$datetime = end( $datetimes );
if ( ! $event->is_sold_out() ) {
// grab array of EE_Ticket objects for event
$tickets = EEH_Event_View::event_tickets_available( $post->ID );
// grab first ticket from array
$ticket = reset( $tickets );
//check if the ticket is free, if set the ticket price to 'Free'
if ( $ticket instanceof EE_Ticket ) {
$ticket_price = $ticket->pretty_price();
$ticket_price_data_value = $ticket->price();
$ticket_price = $ticket_price_data_value == 0 ? __( 'Free', 'event_espresso' ) : $ticket_price;
}
//Get the remaining ticket values for the next datetime.
$tickets_remaining = $datetime->tickets_remaining() === EE_INF ? __('Unlimited','event_espresso') : $datetime->tickets_remaining();
} else {
//The event is sold out, set the ticket price to 'N/A'
$ticket_price = __( 'N/A', 'event_espresso');
}
- At about line 112 (after edit above about line 138) you'll see this line of code:
<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo $startdate; ?></td>
- Replace it with this:
<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo $startdate; ?></td>
<td class="starting_from_pricing event-<?php echo $post->ID; ?>"><?php echo $ticket_price; ?></td>
Then save changes.
In the first code change, we are adding a new column with a column heading of Starting From and adjusting the column value. In the second code change, we adding some supporting coding to get the ticket pricing. In the third code change we are then displaying the price for the ticket in the new column.
If an event is free as in the ticket is zero (0) then the word "Free" will show instead of a numeric value. You can change that verbiage by changing the word Free to something else during step 11. If an event is sold out, then N/A will show for the event price.
References:
http://eventespresso.com/topic/creating-custom-template-ee4-table-view-addon-2/
http://eventespresso.com/topic/add-price-as-separate-column-in-the-events-table-view/#post-148852