Home › Forums › Ticket Products › Event Tickets Plus › Include Attendee Details in Order Email
- This topic has 6 replies, 5 voices, and was last updated 9 years, 5 months ago by
Simon Groves.
-
AuthorPosts
-
October 6, 2016 at 8:06 am #1173212
Simon Groves
ParticipantHi,
I’m trying to include the attendee fields I’ve created into my woocommerce new order email.
Based on another post. I’ve come up with the following:
<?php $fieldset_meta = get_post_meta( $order->id, Tribe__Tickets_Plus__Meta::META_KEY, true ); $i = 1; if (! $fieldset_meta ) return; echo '<h3>Attendee List</h3>'; foreach( $fieldset_meta AS $item => $value ) { foreach( $fieldset_meta[$item] AS $key => $value ) { $att_name = (isset( $value['name'] )) ? $value['name'] : ''; $att_email = (isset( $value['email'] )) ? $value['email'] : ''; $att_phone = (isset( $value['telephone'] )) ? $value['telephone'] : ''; echo '<p>'; echo '<strong>Attendee - '. $i .'</strong><br />'; echo 'Name: '. $att_name .'<br />'; echo 'Email: '. $att_email .'<br />'; echo 'Phone: '. $att_phone .'<br />'; echo '</p>'; $i++; } } ?>Do I simply add this to my woocommerce/emails/email-order-items.php email template (within my theme) or do I need to do anything else? I believe this should work but can’t find much info on it unless I’ve missed the obvious!?
Thanks in advanced.
October 7, 2016 at 7:13 am #1173706Simon Groves
ParticipantHi,
I believe this is now resolved. To help others, I needed to edit 2 files in WooCommerce
I copied these to my theme:
woocommerce/orders/order-details-item.php
woocommerce/emails/email-order-items.phpI added the same code into both templates. In order-details-item.php I placed it before:
do_action( ‘woocommerce_order_item_meta_end’, $item_id, $item, $order );And in email-order-items.php I placed it after:
do_action( ‘woocommerce_order_item_meta_end’, $item_id, $item, $order, $plain_text );This is my code:
#Let's get the attendee info $ticket_product_id = $item['product_id']; $fieldset_meta = get_post_meta( $order->id, Tribe__Tickets_Plus__Meta::META_KEY, true ); $i = 1; if (! $fieldset_meta ) return; foreach( $fieldset_meta AS $item => $value ) { #add conditional otherwise attendee list shows for every ticket. In my case, I have 2 ticket types: Guest and Member, I only collect this for Guests. Not doing this check means the attendee list shows on the member tickets too if ($ticket_product_id == $item){ foreach( $fieldset_meta[$item] AS $key => $value ) { $att_name = (isset( $value['name'] )) ? $value['name'] : ''; $att_email = (isset( $value['email-address'] )) ? $value['email-address'] : ''; $att_phone = (isset( $value['phone-number'] )) ? $value['phone-number'] : ''; $att_company = (isset( $value['company'] )) ? $value['company'] : ''; echo '<p>'; echo '<strong>Attendee - '. $i .'</strong><br />'; echo 'Name: '. $att_name .'<br />'; echo 'Email: '. $att_email .'<br />'; echo 'Phone: '. $att_phone .'<br />'; echo 'Company: '. $att_company .'<br />'; echo '</p>'; $i++; } } }I hope this helps someone!
October 7, 2016 at 12:20 pm #1173868Brook
ParticipantHowdy Simon,
Thank you so much for getting back and sharing your solution. That looks perfect, I am sure others will find it helpful.
Please let us know if you ever need anything else. Cheers!
– Brook
October 10, 2016 at 2:03 am #1174404Sallé Alexander
Participanthello,
it s a very good snippet and i need it for mu client but i have question :
– how can u have the value of the fields ? is it the title of the field ?Because i have 3 ticket flied set with
prenom
nom
email
telephoneso where can i find the value ?
thanks for ur help !
all the best
Alexander
October 11, 2016 at 1:21 pm #1175116Brook
ParticipantHowdy Alex,
You will need to inspect the return of $fieldset_meta to determine your field names. If you have a PHP debugger throwing a breakpoint in there an examining the variable would give you the list. If you do not have a debugger you could add a var_dump after the third line:
var_dump($fieldset_meta);And that will list each of the field names for your site.
I wish I could just give you the list, but the field names will be specific to your site. It might just be “telephone”, or it might be “telephone7” or something like that. So the best way to get the list is to do what I’ve outlined above. 🙂
Cheers!
– Brook
November 2, 2016 at 9:35 am #1186399Support 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 ‘Include Attendee Details in Order Email’ is closed to new replies.
