insert ticket field set with ur snippet on email don’t work

Home Forums Ticket Products Event Tickets Plus insert ticket field set with ur snippet on email don’t work

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1172652
    Sallé Alexander
    Participant

    hello,

    i use this snippet below to insert the fields on the the ticket send by mail but it doesn’t work for me,
    maybe, its my slug name are wrong ( where can i find it ?


    //add_action( 'woocommerce_email_customer_details', 'gum_woo_checkout_fields_email_customer' );
    function gum_woo_checkout_fields_email_customer( $order ) {

    $fieldset_meta = get_post_meta( $order->id, Tribe__Tickets_Plus__Meta::META_KEY, true );
    $cnt = 1;

    if (! $fieldset_meta ) return;

    echo '

    Course Participants

    ';

    foreach( $fieldset_meta AS $item => $value ) {

    foreach( $fieldset_meta[$item] AS $key => $value ) {

    $att_fname = (isset( $value['prenom'] )) ? $value['prenom'] : '';
    $att_lname = (isset( $value['nom'] )) ? $value['nom'] : '';
    $att_email = (isset( $value['email'] )) ? $value['email'] : '';
    $att_phone = (isset( $value['telephone'] )) ? $value['telephone'] : '';
    $att_profession = (isset( $value['profession'] )) ? $value['profession'] : '';
    $att_license = (isset( $value['license'] )) ? $value['license'] : '';

    echo '

    ';
    echo 'Attendee - '. $cnt .'
    ';
    echo 'Name: '. $att_fname .' '. $att_lname .'
    ';
    echo 'Email: '. $att_email .'
    ';
    echo 'Phone: '. $att_phone .'
    ';
    echo 'Profession: '. $att_profession .'
    ';
    echo 'License #: '. $att_license .'
    ';
    echo '

    ';

    $cnt++;

    }

    }
    }

    all the best

    alexender

    #1173692
    Nico
    Member

    Hey Alexander,

    The code looks good to me! I just tried it out (made some minor tweaks) and instead of printing out each field I added a simple var_dump. This way you’ll be able to see the field labels:

    https://gist.github.com/niconerd/b31da56a2c5a96b04079254c59d0bb00

    Please let me know if this works for you,
    Best,
    Nico

    #1174414
    Sallé Alexander
    Participant

    hello,

    yes it work but there is “array’ and “string” displayed…

    is it possible to have only the field like this : prenom: bb

    i send u a screenshot.

    all the best

    Alexander

    #1174416
    Sallé Alexander
    Participant

    the screenshot

    #1175196
    Nico
    Member

    Sure that’s possible Salle!

    Just replace the keys who had there for the correct ones that the output showed:


    Prenom: <?php echo $value['prenom']; ?>

    Does that work for you? Have you tried enabling the commented code?

    Please let me know about it,
    Best,
    Nico

    #1183091
    Shaun
    Participant

    Hi,

    I’m looking to do the same here and have added the amended code from Nico. Thanks to you and also Sallé for the original code.

    However, I’m just getting the full var_dump including the array/string.

    I don’t really understand exactly what I need to replace from the commented out code to just show the field label/value.

    My fieldset is very simple just two fields; attendee name and email address.

    ‘name-of-attendee’ and ’email-address-of-attendee’ (screenshot attached)

    I would be very grateful if somebody could tell me what to change in this code to make it show up in the email just like the ‘Customer Details’ do below.

    echo '<h3>Attendee Info</h3>';
    
    	foreach( $fieldset_meta AS $item => $value ) {
    
    		foreach( $fieldset_meta[$item] AS $key => $value ) {
    
    			echo '<strong>Attendee - '. $cnt .'</strong><br />';
    			echo '<pre>';
    			var_dump( $value );
    			echo '</pre>';
    
    			/*$att_fname         = (isset( $value['prenom'] )) ? $value['prenom'] : '';
    			$att_email         = (isset( $value['email'] )) ? $value['email'] : '';
    
    			echo '<p>';
    			echo '<strong>Attendee - '. $cnt .'</strong><br />';
    			echo 'Name: '. $att_fname .'<br />';
    			echo 'Email: '. $att_email .'<br />';
    			echo '</p>';*/
    
    			$cnt++;
    
    		}
    
    	}
    

    Thanks in advance.

    #1183385
    Nico
    Member

    Hey Shaun,

    Thanks for chiming in! Try this version, which should output the values:


    foreach( $fieldset_meta AS $item => $value ) {

    foreach( $fieldset_meta[$item] AS $key => $value ) {

    echo 'Attendee - '. $cnt .'
    ';
    echo 'Name: ' . $value['name-of-attendee'] . '
    ';
    echo 'Email: ' . $value['email-address-of-attendee'] . '
    ';

    $cnt++;

    }

    }

    Please let me know if that works for you,
    Best,
    Nico

    #1183641
    Shaun
    Participant

    Thanks Nico, that’s perfect!

    #1183902
    Nico
    Member

    Glad to hear Shaun 🙂

    I’ll leave this thread open until Alexander confirm he could make it work in his site.

    Cheers,
    Nico

    #1184283
    Sallé Alexander
    Participant

    hello nico,

    Is it possible to insert the title of the event for each if the user buy multiple ticket ?

    all the best

    Alexander

    #1185566
    Nico
    Member

    Hey Alexander, sure that’s possible just add the following lines in the existing snippet:


    foreach( $fieldset_meta AS $item => $value ) {

    $event_id = get_post_meta ( $item, '_tribe_wooticket_for_event', true );
    if ( !empty ($event_id ) ) echo get_the_title( $event_id );

    foreach( $fieldset_meta[$item] AS $key => $value ) {

    That will echo the event title from which attendees are being fetched. You can move the $cnt = 1; above the new lines so the numbers correlate with each event.

    Please let me know if this works for you,
    Best,
    Nico

    #1195904
    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 12 posts - 1 through 12 (of 12 total)
  • The topic ‘insert ticket field set with ur snippet on email don’t work’ is closed to new replies.