Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Last active July 4, 2023 07:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrasguseo/92597c4690cf5366cdb69e385cc32859 to your computer and use it in GitHub Desktop.
Save andrasguseo/92597c4690cf5366cdb69e385cc32859 to your computer and use it in GitHub Desktop.
Show event title and date on WooCommerce cart page
<?php
/* The snippet shows the event title and event start date on the WooCommerce cart page
* Done with the help of @Rachel ;)
*/
add_filter( 'woocommerce_cart_item_name', 'example_testing', 10, 3 );
function example_testing( $title, $values, $cart_item_key ) {
$ticket_meta = get_post_meta( $values['product_id'] );
$event_id = absint( $ticket_meta['_tribe_wooticket_for_event'][0] );
$venue_id = tribe_get_venue_id( $event_id );
if ( $event_id ) {
$title = sprintf( '%s for <a href="%s" target="_blank"><strong>%s</strong></a> on ', $title, get_permalink( $event_id ), get_the_title( $event_id ), tribe_get_start_date( $event_id ) );
$title .= tribe_get_start_date( $event_id );
if ( $venue_id ) {
$venue = ( tribe_get_venue_details( $venue_id ) );
// Add venue name linked
$title .= " at " . $venue['linked_name'];
// Add venue address
$title .= "<br><small>" . $venue['address'] . "</small>";
}
}
return $title;
}
@Photosynthesis
Copy link

Hi Andras -- thanks for this gist.

Do you know why the Woo product records that Event Tickets Plus creates don't already have the event title in the product title? Seems like an obvious solution and an easy one to implement! Am I missing something?

Without this, even if we use your code to add event info in the cart, it could be quite problematic to track the purchase records and sort out who bought tickets to what event in the WooCommerce data (for us, this is a primary reason to use ETP -- so we can integrate event attendees with our relationship management for Woo customers).

Any advice on this?

@voneff
Copy link

voneff commented Feb 23, 2021

@Photosynthesis - hi there!
I am looking at the same problem as you last year. Did you work this out? Would you mind sharing your solution? I'd really appreciate a little push in the right direction... cheers!

@andrasguseo
Copy link
Author

Hi @Photosynthesis and @voneff

Good question, I don't know why it was implemented like that. I will try to check with the developers to get some insights on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment