Skip to content

Instantly share code, notes, and snippets.

@geoffgraham
Last active September 18, 2015 21:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save geoffgraham/145f929f4547bb2c690e to your computer and use it in GitHub Desktop.
Save geoffgraham/145f929f4547bb2c690e to your computer and use it in GitHub Desktop.
WooCommerce Tickets 3.9.3 // 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