Adding custom field to email.php on Event Tickets

Home Forums Ticket Products Event Tickets Plus Adding custom field to email.php on Event Tickets

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1166965
    Orla
    Participant

    This is an update to this ticket: https://theeventscalendar.com/support/forums/topic/acf-display-in-email-template/#post-1152062

    Aim: Add a custom field with the registration URL of the event into the Ticket Email.

    Here is the code:

    <h2>Webinar Details:</h2>										
        <?php
             $webinarURL = get_field( 'webinarLink' );
             if( $webinarURL ) {
                 echo '<a href="' . $webinarURL . '" target="_blank">WEBINAR REGISTRATION</a>';
             } else {
                 echo 'empty';
             }
        ?>

    This works for projects but when I try to implement it on the following template: /plugins/event-tickets/src/views/event-tickets/tickets/email.php I am constantly getting:

    Webinar Details
    Empty

    The webinarLink field is definitely filled in with the same url on both the project page and the event page.

    I know Geoff was able to get it working on his end – I am mystified as to why I cannot get it working. It just doesn’t seem to be able to pick up the custom field but the if statement is working.

    Do you have any idea why this is happening?

    Kind Regards,
    Orla

    #1167424
    Nico
    Member

    Hi there Orla,

    Thanks for getting in touch and for the detailed description of this issue!

    I just tried it locally and indeed wasn’t working for me either. I found that it’s necessary to add the event ID to the get_field function, also the field identifier should be all lower case (although I think ACF handles this gracefully). So the final code that’s working on my side is:

    Webinar Details:

    ID ) ) {
    echo 'WEBINAR REGISTRATION';
    } else {
    echo 'empty';
    }
    ?>

    Maybe Geoff was placing the code in a different part of the template that had the global $post_id set? Not sure about it.

    One more thing, it’s ok to actually try this in /plugins/event-tickets/src/views/event-tickets/tickets/email.php, but as it’s a plugin file it will get overwritten in future updates. To be safe create a template override of the file (as explained in our themer’s guide) and add the custom code there.

    Please give this a try and let me know about it,
    Best,
    Nico

    #1167825
    Orla
    Participant

    This reply is private.

    #1168106
    Nico
    Member

    This reply is private.

    #1169108
    Orla
    Participant

    This reply is private.

    #1169513
    Nico
    Member

    This reply is private.

    #1169776
    Orla
    Participant

    This reply is private.

    #1170317
    Nico
    Member

    This reply is private.

    #1180647
    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 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Adding custom field to email.php on Event Tickets’ is closed to new replies.