Home › Forums › Ticket Products › Event Tickets Plus › Link a new event to an existing ticket
- This topic has 4 replies, 3 voices, and was last updated 10 years, 7 months ago by
Support Droid.
-
AuthorPosts
-
September 7, 2015 at 12:49 pm #1002715
xrossglobalgroup
ParticipantHello, I previously posted the following forum: https://theeventscalendar.com/support/forums/topic/link-event-to-existing-ticket/
My developer is not able to figure out what to do and wanted to know this:
We are trying to add an existing Woo Commerce product to a new event, without actually creating a new Woo commerce product in that event (lower part of the backend). In which table should we add the entry for a particular event?
Thanks for your help.
September 7, 2015 at 1:25 pm #1002728Nico
MemberHi there @xrossglobalgroup,
Glad to help you once again on this one!
The table that links the event with the ticket is the wp_postmeta table. The SQL code to create that link is the following:
INSERT INTO wp_postmeta ('meta_id', 'post_id', 'meta_key', 'meta_value) VALUES (NULL, -PRODUCT_ID-, '_tribe_wooticket_for_event', -EVENT_ID-);
You can achieve the same thing via PHP, using the following code:
function tribe_link_product_event ( $product_id, $event_id ) {
if ( !in_array($event_id, get_post_meta( $product_id, '_tribe_wooticket_for_event')) ) {
add_post_meta( $product_id, '_tribe_wooticket_for_event', $event_id );
}
}
Please let me know if this helps you getting it sorted out,
Best,
NicoSeptember 7, 2015 at 10:02 pm #1002777xrossglobalgroup
ParticipantThis reply is private.
September 9, 2015 at 6:57 am #1003218Nico
MemberHi Edgar,
Thanks for following up on this. Unfortunately we are not allowed to log into client sites to make changes 🙁
Can you test this out once again please? I just tested it in my local install and it’s working.
This can be used in more elegant/functional ways, but just to test if this works at all on your end, add this snippet to your theme’s functions.php file -located at wp-content/themes/your_theme/ :
add_action( 'admin_init', 'link_product_with_tickets' );function link_product_with_tickets ( ){
tribe_link_product_event ( replace_with_ticket_id , replace_with_event_id );
}function tribe_link_product_event ( $product_id, $event_id ) {
if ( !in_array($event_id, get_post_meta( $product_id, '_tribe_wooticket_for_event')) ) {
add_post_meta( $product_id, '_tribe_wooticket_for_event', $event_id );
}
}
Make sure to replace the sample strings with the corresponding id’s (just the number). Once the code is in place go to edit page of the event in the back-end and refresh. After doing so you should see the ticket linked.
Please let me know about this test,
Best,
NicoSeptember 24, 2015 at 7:05 am #1008243Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Link a new event to an existing ticket’ is closed to new replies.
