Displaying fields in email.php that aren’t included in the default template

Home Forums Ticket Products Event Tickets Plus Displaying fields in email.php that aren’t included in the default template

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #75240
    callanwolde
    Participant

    I’ve scoured all of the documentation and primers over and over. I have my customized email.php working in my child theme. There are a few data points that I’d like to use but I can’t seem to find the right calls for them. [QUESTION 1] Do you have a list of available calls AND how they need to be referenced in the email.php? This has been holding me back from fully customizing the email.

    For example:
    I need the original face-value of the ticket. I tried this unsuccessfully on a free event (I assumed it would show $0 or “Free”):
    echo tribe_get_cost( $event->ID );

    Also, I need to display the data from a custom field that will only display on the email and not on the event page on the website. This is for event-specific instructions such as parking locations. I created a custom text field through Events > Settings > Additional Fields with a field label of “Additional Info on Emailed Tickets”. [QUESTION 2] How can I display the contents in my email.php? [QUESTION 3] Does the (tiny) text input box accept HTML or will it get stripped? I assumed incorrectly that the Additional Fields tab would also show me the field name to use in my code. I tried this unsuccessfully:
    echo tribe_get_custom_field(‘_ecp_custom_1’, $event->ID)

    #75241
    callanwolde
    Participant

    (P.S. Love your products, but this forum input could use some serious formatting help!)

    #75798
    Barry
    Member

    Hi callanwolde,

    There are definitely some areas of the forum that could do with a little TLC and we do hope to get on top of that at some point – it’s been a lower priority than product development and support though and unfortunately that means it doesn’t always offer an ideal environment to share code and troubleshoot issues – so please accept our apologies on that front.

    You’ve asked what are really quite a few different questions so I’ll try my best to answer them in turn, but it may be best to break them out into separate threads (bearing in mind much of this comes down to custom development and so we can’t always offer too much help with everything you’ve detailed).

    Event cost

    The tribe_get_cost() function probably isn’t going to operate quite as you might expect if you are concerned with the price of a WooCommerce Tickets product since that field (the event cost) is really just intended as a way to communicate pricing when no ticketing add-ons are in use.

    What you probably want to do here is obtain the WooCommerce product object and grab the price that way. Delving in to WooCommerce’s own documentation is probably a good idea here.

    I wrote a set of helpers to make this sort of work easier and there are some sample recipes to show how it works. However, please do note that isn’t an official Modern Tribe project but simply some code that is available for you to try if you want (and at your own risk!) – but it might be helpful here.

    Additional fields

    You’ll find you can use a few HTML tags but others may be stripped. For example, a <strong> tag should work without any issue. The best thing to do here is experiment 🙂

    echo tribe_get_custom_field('_ecp_custom_1', $event->ID)

    This isn’t an uncommon mistake – but really you need to pass in the field label when working with tribe_get_custom_field() (in other words, the “human readable” name given to the field, such as “My special field”).

    Hope that helps!

    #77478
    callanwolde
    Participant

    Barry, thank you.
    I was able to add the custom field to the email. However, I don’t want it to display on the actual event page. I can’t hide it with CSS because it doesn’t have a unique class (All of the event meta sections are .tribe-events-meta-group). And I can’t find any code snippets from the documentation that will help me. I read through https://theeventscalendar.com/support/forums/topic/trying-to-hide-metadata-in-the-3-version/ and its related links, but still no joy for hiding only the custom fields. Any help here?

    It looks like getting the individual ticket price into the email template is over my head. If you’ve thought of another way to include the individual ticket price in the /tickets/email.php template, please do let me know. Showing the price on a purchased ticket seems like a basic need for any ticketing template, so please take this as a feature request.

    Thank you!
    -Kenny

    #77768
    Barry
    Member

    Do you want to hide just this specific field? Or all custom fields?

    #77860
    callanwolde
    Participant

    I’d rather hide all of the custom fields, including the .tribe-events-meta-group container. But I’d settle for just hiding the one.

    #78267
    Barry
    Member

    You could certainly hide them pretty easily with some custom CSS:

    .tribe-events-event-meta .tribe-events-meta-group-other { display: none; }

    #78573
    Kelly
    Participant

    Hi, Kenny. I just wanted to check in and see if you were able to try Barry’s snippet. We’d love to hear how it worked for you!

    Thanks!

    #78713
    callanwolde
    Participant

    Kelly and Barry,
    That CSS snippet does not work because the target class .tribe-events-meta-group-other doesn’t exist. That was the first solution I looked for (and the reason for the whole problem). All of the meta divs have the same class of .tribe-events-meta-group

    Here’s a screenshot of my Chrome inspector showing the HTML output that I have to work with: http://img33.imageshack.us/img33/1779/6vym.png

    As of now, I’ve had to rely on a super-hacky jquery fix I made. It’s not ideal and I’d appreciate a non-hack solution if there’s one to be had.

    Thanks!
    Kenny

    #78714
    callanwolde
    Participant

    FYI, in that screenshot (http://img33.imageshack.us/img33/1779/6vym.png), I highlighted the fourth div, which is the one that I’m trying to target. The “display:block” on the third div is a result of my jQuery hack, so that would be removed if you guys have a real solution. Thanks, Kenny.

    #78767
    Barry
    Member

    Hi Kenny,

    As you can appreciate it isn’t quite so easy to work things out based on screenshots alone – so I’m having to rest on some assumptions which I guess may not be true in your case.

    You could consider using the :last-child pseudo selector if you want to use a CSS approach to hiding that div and don’t wish to rely on JS; alternatively you might prefer to stop that div from being generated in the first place (and so you could investigate our meta walker documentation).

    Really though this is a customization and beyond offering some general pointers we’ll have to leave you to figure out the details here.

    Good luck!

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Displaying fields in email.php that aren’t included in the default template’ is closed to new replies.