Home › Forums › Ticket Products › Event Tickets Plus › Displaying fields in email.php that aren’t included in the default template
- This topic has 10 replies, 3 voices, and was last updated 12 years, 4 months ago by
Barry.
-
AuthorPosts
-
November 7, 2013 at 1:48 pm #75240
callanwolde
ParticipantI’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)November 7, 2013 at 1:50 pm #75241callanwolde
Participant(P.S. Love your products, but this forum input could use some serious formatting help!)
November 12, 2013 at 10:10 am #75798Barry
MemberHi 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!
November 19, 2013 at 12:22 pm #77478callanwolde
ParticipantBarry, 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!
-KennyNovember 20, 2013 at 5:15 pm #77768Barry
MemberDo you want to hide just this specific field? Or all custom fields?
November 21, 2013 at 9:46 am #77860callanwolde
ParticipantI’d rather hide all of the custom fields, including the .tribe-events-meta-group container. But I’d settle for just hiding the one.
November 22, 2013 at 2:55 pm #78267Barry
MemberYou could certainly hide them pretty easily with some custom CSS:
.tribe-events-event-meta .tribe-events-meta-group-other { display: none; }November 25, 2013 at 6:38 pm #78573Kelly
ParticipantHi, 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!
November 26, 2013 at 11:32 am #78713callanwolde
ParticipantKelly 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-groupHere’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!
KennyNovember 26, 2013 at 11:35 am #78714callanwolde
ParticipantFYI, 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.
November 26, 2013 at 5:05 pm #78767Barry
MemberHi 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!
-
AuthorPosts
- The topic ‘Displaying fields in email.php that aren’t included in the default template’ is closed to new replies.
