Oguzhan Altun
April 19, 2015 at 3:05 pm
Hello,
One of my events is full, and for some reason it shows “Free” in the ticket price column in the EE Table view. http://www.genevaphotoclub.com/dates-prices/
There is no free ticket, it should show 99chf.
Here is the related code I could find in the table-template.php for the price display, could you let me know what’s wrong?
$ticket_price = $ticket instanceof EE_Ticket ? sprintf(“%0.2f”,$ticket->ticket_price()) . ‘<span class=”currency-code”> (CHF)</span>’ : ”;
$ticket_price_data_value = $ticket instanceof EE_Ticket ? $ticket->price() : ”;
$tickets_price_free_check = $ticket_price_data_value == 0 ? __(‘Free’,’event_espresso’) : (float)$ticket_price_data_value . ‘<span class=”currency-code”> (CHF)</span>’;
<td style=”text-align:center” class=”starting_from_pricing event-<?php echo $post->ID; ?>”><?php echo $tickets_price_free_check; ?></td>
Dean
April 20, 2015 at 5:12 am
Add New Note to this Reply
What if you add this line, below the existing line starting with $tickets_price_free_check
$tickets_price_free_check = (string)$ticket_price_data_value == '' ? __('Sold Out','event_espresso') : $tickets_price_free_check;
Oguzhan Altun
April 20, 2015 at 5:39 am
Add New Note to this Reply
hello,
now it says “sold-out” instead of “free”. How can I make it show the original price of the event? The price column should look exactly the same as the events which are not yet full.
Lorenzo Orlando Caum
April 21, 2015 at 2:13 pm
Add New Note to this Reply
Hi, the code snippet that you posted appears to be missing some items at the top. Try this:
// grab array of EE_Ticket objects for event
$tickets = espresso_event_tickets_available( $post->ID, FALSE, FALSE );
// grab first ticket from array
$ticket = array_shift( $tickets );
$ticket_price = $ticket instanceof EE_Ticket ? sprintf("%0.2f",$ticket->ticket_price()) . ' (CHF) ' : '';
$ticket_price_data_value = $ticket instanceof EE_Ticket ? $ticket->price() : '';
$tickets_price_free_check = $ticket_price_data_value == 0 ? __('Free','event_espresso') : $ticket_price;
It should then appear similar to this:
http://cl.ly/image/10363N3w2w40
Note: this is equivalent to step 9 here:
https://gist.github.com/lorenzocaum/ef6afefd07c9c5f6f681
—
Lorenzo
Oguzhan Altun
April 22, 2015 at 6:16 am
Add New Note to this Reply
Hello,
This didn’t change anything, still shows free without Dean’s addition, and shows “Sold Out” if I add Dean’s code after yours. Here is the full code of the php so you can have a look
<?php
// Options
$date_format = get_option( 'date_format' );
$time_format = get_option( 'time_format' );
// Load Venue View Helper
EE_Registry::instance()->load_helper('Venue_View');
//Defaults
$reg_button_text = !isset($reg_button_text) ? __('Register', 'event_espresso') : $reg_button_text;
$alt_button_text = !isset($alt_button_text) ? __('View Details', 'event_espresso') : $alt_button_text;//For alternate registration pages
$sold_out_button_text = !isset($sold_out_button_text) ? __('Sold Out', 'event_espresso') : $sold_out_button_text;//For sold out events
if ( have_posts() ) :
// allow other stuff
do_action( 'AHEE__espresso_events_table_template_template__before_loop' );
?>
<?php if ($category_filter != 'false'){ ?>
<p class="category-filter">
<label><?php echo __('Category Filter', 'event_espresso'); ?></label>
<select class="" id="ee_filter_cat">
<option class="ee_filter_show_all"><?php echo __('Show All', 'event_espresso'); ?></option>
<?php
$taxonomy = array('espresso_event_categories');
$args = array('orderby'=>'name','hide_empty'=>true);
$ee_terms = get_terms($taxonomy, $args);
foreach($ee_terms as $term){
echo '<option class="' . $term->slug . '">'. $term->name . '</option>';
}
?>
</select>
</p>
<?php } ?>
<?php if ($footable != 'false' && $table_search != 'false'){ ?>
<p>
<?php echo __('Search:', 'event_espresso'); ?> <input id="filter" type="text"/>
</p>
<?php } ?>
<table id="ee_filter_table" class="espresso-table footable table" data-page-size="<?php echo $table_pages; ?>" data-filter="#filter">
<thead class="espresso-table-header-row">
<tr>
<th class="th-group"><?php _e('Date','event_espresso'); ?></th>
<th class="th-group"><?php _e('Day','event_espresso'); ?></th>
<th class="th-group"><?php _e('Time','event_espresso'); ?></th>
<th class="th-group"><?php _e('Course','event_espresso'); ?></th>
<th class="th-group"><?php _e('Price','event_espresso'); ?></th>
<th class="th-group" data-sort-ignore="true"></th>
</tr>
</thead>
<?php if ($footable != 'false' && $table_paging != 'false'){ ?>
<tfoot>
<tr>
<td colspan="4">
<div class="pagination pagination-centered"></div>
</td>
</tr>
</tfoot>
<?php } ?>
<tbody>
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
// Include the post TYPE-specific template for the content.
global $post;
//Debug
//d( $post );
//Get the category for this event
$event = EEH_Event_View::get_event();
if ( $event instanceof EE_Event ) {
if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
// loop thru terms and create links
$category_slugs = '';
foreach ( $event_categories as $term ) {
$category_slugs[] = $term->slug;
}
$category_slugs = implode(' ', $category_slugs);
} else {
// event has no terms
$category_slugs = '';
}
}
//Create the event link
$external_url = $post->EE_Event->external_url();
$button_text = !empty($external_url) ? $alt_button_text : $reg_button_text;
$registration_url = !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink();
//Create the register now button
$live_button = '<a class="register-button" id="a_register_link-'.$post->ID.'" href="'.$registration_url.'">'.$button_text.'</a>';
if ( $event->is_sold_out() || $event->is_sold_out(TRUE ) ) {
$live_button = '<a id="a_register_link-'.$post->ID.'" class="soldout-button" href="'.$registration_url.'">'.$sold_out_button_text.'</a>';
}
$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 );
foreach ( $datetimes as $datetime ) {
$startdat = $datetime->start_date();
}
// grab array of EE_Ticket objects for event
$tickets = espresso_event_tickets_available( $post->ID, FALSE, FALSE );
// grab first ticket from array
$ticket = array_shift( $tickets );
$ticket_price = $ticket instanceof EE_Ticket ? sprintf("%0.2f",$ticket->ticket_price()) . ' (CHF)' : '';
$ticket_price_data_value = $ticket instanceof EE_Ticket ? $ticket->price() : '';
$tickets_price_free_check = $ticket_price_data_value == 0 ? __('Free','event_espresso') : $ticket_price;
// Dean Add so that it doesn't show free for full events
$tickets_price_free_check = (string)$ticket_price_data_value == '' ? __('Sold Out','event_espresso') : $tickets_price_free_check;
// grab primary datetime for event
$first_datetime = espresso_event_date_obj( $post->ID );
$tickets_left = $first_datetime instanceof EE_Datetime ? $first_datetime->tickets_remaining() : 0;
$tickets_left = $tickets_left === INF ? __('unlimited','event_espresso') : $tickets_left;
?>
<tr class="espresso-table-row <?php echo $category_slugs; ?>">
<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo strtotime( $startdat ); ?>"><?php echo $startdat; ?></td>
<td class="day_of_week event-<?php echo $post->ID; ?>"><?php echo espresso_event_date_range( 'l', ' ', ' ', ' ', $event->ID() ); ?></td>
<td class="day_of_week event-<?php echo $post->ID; ?>"><?php echo espresso_event_date_range( 'G:i', ' ', ' ', ' ', $event->ID() ); ?></td>
<td class="event_title event-<?php echo $post->ID; ?>"><?php echo $post->post_title; ?></td>
<td style="text-align:center" class="starting_from_pricing event-<?php echo $post->ID; ?>"><?php echo $tickets_price_free_check; ?></td>
<td style="text-align:center" class="td-group reg-col" nowrap="nowrap"><?php echo $live_button; ?></td>
</tr>
<?php
endwhile;
echo '</table>';
// allow moar other stuff
do_action( 'AHEE__espresso_events_table_template_template__after_loop' );
else :
// If no content, include the "No posts found" template.
espresso_get_template_part( 'content', 'none' );
endif;
Lorenzo Orlando Caum
April 24, 2015 at 7:23 am
Add New Note to this Reply
Hi, I copied your code sample out and loaded it onto my testing site and it looks okay there:
http://cl.ly/image/070L1n363W0o
—
Lorenzo
Oguzhan Altun
April 24, 2015 at 10:29 am
Add New Note to this Reply
?? I don’t understand, what could be wrong in my website’s version then??
Lorenzo Orlando Caum
April 24, 2015 at 12:46 pm
Add New Note to this Reply
Hi, on the event that is sold out, are there any other options specified?
Could you post a screenshot of the ticket editor?
https://eventespresso.com/wiki/troubleshooting-checklist/#screenshots
I want to see if I can created a similar sold out event on my test site.
—
Lorenzo
Lorenzo Orlando Caum
March 25, 2016 at 7:10 pm
Add New Note to this Reply
Hello,
I updated the tutorial as I found that it showed free when becoming sold out due to ticket sales but not when manually sold out. Go ahead and update using the updated version to resolve that issue:
https://gist.github.com/lorenzocaum/ef6afefd07c9c5f6f681
Note that the line numbers are based off starting with a default version of the file.
Also, one of the main conditions that it is checking for is information for available tickets. Those tickets are no longer available once the event becomes sold out (i.e. the pricing information isn’t available anymore). In the updated example, N/A is used. Feel free to change that text to something that better fits your needs but again the pricing itself is not available on a sold out event.
Thanks
—
Lorenzo