Home › Forums › Ticket Products › Event Tickets Plus › Wrong ticket_id in email template
- This topic has 5 replies, 2 voices, and was last updated 8 years, 7 months ago by
TAO.
-
AuthorPosts
-
August 16, 2017 at 6:39 am #1335969
TAO
Participanti’m working on an email template for a client. Specifically
tribe-events/tickets/email.php.
I need the ticket_id provided with the$ticketsarray to grab additional informations saved as meta fields on the particular (woocommerce) product.My problem is that the ticket_id is sometimes* wrong and in turn prevents me from providing the appropriate informations to the user. How can I make sure the ticket_id provided to the email template is correct every time?
* sometimes being when the payment through woocommerce+paypal either fails or is cancelled by the user and then subsequently the same order is completed normally.
August 17, 2017 at 3:55 pm #1337088Victor
MemberHi There!
Thanks for reaching out to us! I’d be happy to help you with this.
The ticket_id is unique for each attendee, so I’m not sure how you are fetching product metadata with it. Could you please share the code with us?
Also, it seems strange that the ticket_id changes depending on the order status. If it is the same order, it should remain the same ticket. Could you please tell me what steps you made that results in the ticket_id changing?
Thanks,
VictorAugust 18, 2017 at 1:03 am #1337229TAO
ParticipantHi Victor,
Apologies, I was actually looking at the wrong thing. The ticket_id is correct, but the _tribe_wooticket_order_item which is saved as meta value for that ticket is incorrect.
This happens with either this code:
$wooticket = get_posts( array( 'post_type' => 'tribe_wooticket', 'meta_key' => '_unique_id', 'meta_value' => $ticket['ticket_id'], 'posts_per_page' => 1 ) ); if ( !$wooticket ) { // Some more detailed error logging here. error_log( 'error' ); } $oiid = get_post_meta( $wooticket[0]->ID, '_tribe_wooticket_order_item', true ); // <-- this is where I get the wrong value $oi = new WC_Order_Item_Product( $oiid );and also with this:
$oi = new WC_Order_Item_Product( $ticket['order_item_id'] );(all being inside the [theme]/tribe-events/tickets/email.php template)
($ticket in both cases is one element of the $tickets[] array provided to the template by event tickets plus)Workflow to reproduce this issue 100%:
- Add ticket to cart
- Checkout to PayPal
- Cancel on the PayPal site, get redirected to shopping cart
- Checkout to PayPal again
- Complete Paypal Payment
I always get an ID that’s too low (594 when it should be 596)
August 18, 2017 at 12:46 pm #1337539Victor
MemberHi @TAO!
Thanks for clearing that out!
First, let me note we are limited in how much support we can give for custom development questions like that.
That said, we always like helping out and at least point users in the right direction. So let me try to help you with this.
The ‘_tribe_wooticket_order_item’ will give you the order item in the event and not in WooCommerce. You might want to try with the ‘_tribe_wooticket_order’ meta key like this:
get_post_meta( $wooticket[0]->ID, '_tribe_wooticket_order', true );
Will that give you the result you want? Let me know about it
Best,
VictorSeptember 9, 2017 at 9:36 am #1347098Support 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 ‘Wrong ticket_id in email template’ is closed to new replies.
