– Add ticket description column to the event table and cart
A recipe for adding a “Description” column to the ticket-type table and cart — useful when ticket-type names alone aren’t self-explanatory and you want a short description (“Includes lunch and afternoon workshop”) visible at point of purchase.
In case you want to add ticket description column to your event table and cart you just have to add this to your functions.php file:
function tc_the_content_by_id($post_id = 0, $more_link_text = null, $stripteaser = false) {
global $post;
$post = &get_post($post_id);
setup_postdata($post, $more_link_text, $stripteaser);
return get_the_content();
wp_reset_postdata($post);
}
add_action('tc_cart_col_value_before_ticket_price', 'tc_cart_col_value_before_ticket_price_add', 10, 1);
add_action('tc_event_col_value_before_ticket_price', 'tc_cart_col_value_before_ticket_price_add', 10, 1);
function tc_cart_col_value_before_ticket_price_add($ticket_type) {
echo '<td class="ticket-description">' . tc_the_content_by_id($ticket_type) . '</td>';
}
add_action('tc_cart_col_title_before_ticket_price', 'tc_cart_col_title_before_ticket_price_add');
add_action('tc_event_col_title_before_ticket_price', 'tc_cart_col_title_before_ticket_price_add');
function tc_cart_col_title_before_ticket_price_add() {
?>
<th><?php _e('Description', 'tc'); ?></th>
<?php
}
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.