-
-
Save theeventscalendar/20c33934cc2330fea537 to your computer and use it in GitHub Desktop.
Add event title to cart next to ticket name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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