Forked from andrasguseo/show-event-details-on-cart.php
Last active
July 4, 2023 08:47
-
-
Save darookee/9d89766c720691861516679d036f15fb to your computer and use it in GitHub Desktop.
Show event title and date on WooCommerce cart page
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 | |
add_filter( 'woocommerce_cart_item_name', 'krbu_event_title', 10, 3 ); | |
function krbu_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]); | |
$venue_id = tribe_get_venue_id($event_id); | |
if ($event_id) { | |
$eventLink = get_permalink($event_id); | |
if (!stristr($title, $eventLink)) { | |
$title = sprintf( '%s for <a href="%s" target="_blank"><strong>%s</strong></a> on %s', $title, $eventLink, get_the_title($event_id), tribe_get_start_date($event_id)); | |
if ($venue_id) { | |
$venue = tribe_get_venue_details($venue_id); | |
$title = sprintf('%s at %s<br /><small>%s</small>', $title, $venue['linked_name'], $venue['address']); | |
} | |
} | |
} | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternatively one could use the
woocommerce_cart_item_remove_link
filter to fix this: