Include Attendee Details in Order Email

Home Forums Ticket Products Event Tickets Plus Include Attendee Details in Order Email

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1173212
    Simon Groves
    Participant

    Hi,

    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.

    #1173706
    Simon Groves
    Participant

    Hi,

    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.php

    I 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!

    #1173868
    Brook
    Participant

    Howdy 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

    #1174404
    Sallé Alexander
    Participant

    hello,

    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
    telephone

    so where can i find the value ?

    thanks for ur help !

    all the best

    Alexander

    #1175116
    Brook
    Participant

    Howdy 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

    #1186399
    Support Droid
    Keymaster

    Hey 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Include Attendee Details in Order Email’ is closed to new replies.