Home › Forums › Ticket Products › Event Tickets Plus › Add event title to WooCommerce order item title
- This topic has 8 replies, 3 voices, and was last updated 7 years, 9 months ago by
Josh Kern.
-
AuthorPosts
-
July 5, 2018 at 12:50 pm #1568634
Josh Kern
ParticipantI’d like to add the event title to ticket order items. I’m currently using the following function, but it’s only outputting ” – Upcoming Events”, not the actual event title.
function woocommerce_order_item_name_event_title( $title, $item ) { $event = tribe_events_get_ticket_event( $item['product_id'] ); if ( $event !== false ) { $title .= sprintf( ' - <a href="%1$s">%2$s</a>', get_permalink( $event ), tribe_get_events_title( $event ) ); } return $title; } add_filter( 'woocommerce_order_item_name', 'woocommerce_order_item_name_event_title', 100, 2 );If I try get_the_title, I only get the current page title, like “Order received” or “Order #…” if I’m on the view order page, so it’s not getting the event title based on the event id.
Any help would be appreciated.
July 6, 2018 at 10:05 am #1569429Cliff
MemberHi, Josh. I’m unsure if this existing snippet will also apply for the situation you’re wanting, but you might give it a shot:
https://gist.github.com/cliffordp/c012f2945a22867a3af2c2878e06fffd
Please reference https://theeventscalendar.com/knowledgebase/implementing-custom-code-snippets/ for how to implement custom code snippets.
Of course, we always recommend restorable database and file backups as well as performing modifications first on a staging site before modifying anything on your live/production site — particularly for this snippet since it will change Products’ visibility settings.
Please let me know how this goes for you.
July 6, 2018 at 10:15 am #1569444Josh Kern
ParticipantSeems like this isn’t applicable to my situation. Please see attached screenshot. I’m trying to add the event name to the product name using the woocommerce_order_item_name hook.
July 6, 2018 at 12:29 pm #1569587Cliff
MemberThere’s an action and then a filter in that snippet I shared.
With the action not in place, just the filter, this is what I see in my testing:
- Order confirmation page: https://cl.ly/3v252A3i2R0T
- Order email: https://cl.ly/112Y203g0k1V
Therefore, it appears to accomplish what you’re wanting.
If you don’t agree, please specify why this wouldn’t work for you.
July 6, 2018 at 3:51 pm #1569715Josh Kern
ParticipantI don’t think you shared the right snippet. I found the solution I was looking for on this thread: https://theeventscalendar.com/support/forums/topic/duplicate-ticket-emails/
/** * Add event title to order line item. */ add_filter( 'woocommerce_order_item_name', 'sq_woocommerce_order_item_name', 10, 2 ); function sq_woocommerce_order_item_name( $name, $item ) { $event = tribe_events_get_ticket_event( $item['product_id'] ); if ( $event ) { $link = get_permalink( $event->ID ); $event_date = tribe_get_start_date( $event->ID, $display_time = true, 'M j \a\t g:ia' ); $name = $name . ' for <a href="' . $link . '">' . $event->post_title . '</a> - ' . $event_date; } return $name; }July 9, 2018 at 3:10 pm #1571108Cliff
MemberI’m glad you got what you were looking for. Note that get_permalink() could be replaced with tribe_get_event_link()
Please let me know if you have any follow-up questions on this topic.
July 10, 2018 at 7:18 am #1571550webseo
Participantwould love to add it too in our cart. we have hundreds of repeating events (courses) each month and the name and dates of events are important in the cart.
Where should I add this code snippet?July 10, 2018 at 7:34 am #1571565webseo
ParticipantI was able to create a “functionality plugin” and this code is wodnerful for adding th “event” name in Order receipt.
Ho to add Vent name in cart as well???July 10, 2018 at 1:38 pm #1572056Cliff
MemberAgain, I’ll point you to the gist snippet I previously shared at https://theeventscalendar.com/support/forums/topic/add-event-title-to-woocommerce-order-item-title/#post-1569429
And, again, I’ll note the gist snippet includes 2 functions, one leveraging an action (you said you don’t want this functionality) and one leveraging a filter (the functionality you probably want): https://theeventscalendar.com/support/forums/topic/add-event-title-to-woocommerce-order-item-title/#post-1569587
Please let me know how this goes for you.
August 1, 2018 at 9:35 am #1587703Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Add event title to WooCommerce order item title’ is closed to new replies.
