Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theeventscalendar/20c33934cc2330fea537 to your computer and use it in GitHub Desktop.
Save theeventscalendar/20c33934cc2330fea537 to your computer and use it in GitHub Desktop.
Add event title to cart next to ticket name
<?php
/**
* Example for adding event data to WooCommerce checkout for Events Calendar tickets.
* @link http://theeventscalendar.com/support/forums/topic/event-title-and-date-in-cart/
*/
add_filter( 'woocommerce_cart_item_name', 'woocommerce_cart_item_name_event_title', 10, 3 );
function woocommerce_cart_item_name_event_title( $title, $values, $cart_item_key ) {
$ticket_meta = get_post_meta( $values['product_id'] );
$event_id = absint( $ticket_meta['_tribe_wooticket_for_event'][0] );
if ( $event_id ) {
$title = sprintf( '%s for <a href="%s" target="_blank"><strong>%s</strong></a>', $title, get_permalink( $event_id ), get_the_title( $event_id ) );
}
return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment