Home › Forums › Calendar Products › Events Calendar PRO › Add Custom text to Price in Upcoming Events List
- This topic has 13 replies, 3 voices, and was last updated 8 years, 1 month ago by Support Droid.
-
AuthorPosts
-
January 15, 2016 at 4:02 am #1056393AindreasParticipant
Hello,
Im designing a website for a charity which hosts several events. Some of these events are by donation. I need to be able to have the word ‘Donation’ where the price is displayed. It can be next to the price.
I have played around with the php file for the upcoming events list, and have altered the way it looks and displays information (partly thanks to the great support here), but all I would be able to do there is change all of the events listed to display ‘Donation’, which is not what I need.
If possible, is there a way to incorporate one of the Custom Fields sections to display ‘Donation’ next to the price if selected?
If so, could you point me in the right direction of where to look and how to incorporate it into the upcoming events widget?
Any help would be greatly appreciated!Kind Regards,
AindreasJanuary 15, 2016 at 7:54 am #1056651BarryMemberHi Aindreas,
So suppose you set up a checkbox-style additional field, giving you an option like this in the event editor:
You could then add the following code to your theme’s functions.php file or indeed to a custom plugin:
function event_list_donation_marker( $cost, $post_id ) { // Only add the donation marker in list view if ( ! tribe_is_list_view() ) return $cost; $fields = tribe_get_custom_fields( $post_id ); if ( ! empty( $fields['Donation'] ) && 'Yes' === $fields['Donation'] ) $cost .= ' BY DONATION '; return $cost; } add_filter( 'tribe_get_cost', 'event_list_donation_marker', 100, 2 );
Does that help?
January 16, 2016 at 3:54 am #1056932AindreasParticipantThank you for the quick response!
I added the custom field through the events calendar settings and created the Donation section with Yes and No checkboxes. I then copied the code you posted and put it in the functions.php file.
However, it does not seem to work, though I do really like the approach you are taking. The website works as it normally does, it isnt throwing up a PHP error.
Im sure there must be something small that is preventing this from working, any ideas on what it may be?Thanks again!
Kind Regards,
AindreasJanuary 17, 2016 at 9:42 am #1057514BarryMemberCan you share your code (and let me know which file it is in) and also share a screenshot of your additional field settings?
Please consider linking to Gist or Pastebin when sharing your code – it’s a lot easier to read there than when it is pasted directly here in the forum – and, as you cannot upload images here, please share your screenshot by hosting it on your WordPress site or some place else (and simply link to it in your next reply).
Last but not least, though I can take a further peek at this, please do note that custom dev tasks are really something we need to leave in your hands and you should treat any code we share here for these kinds of things as a starting point/rough outline only 🙂
Thanks!
February 3, 2016 at 3:50 am #1066751AindreasParticipantHello,
The code I used was a direct copy of the code you posted, which I put in my ‘funtions.php’ file in the child theme of my site.
Here is the code I copied from my site:
http://pastebin.com/si7FFvfrHere is a screenshot of the checkbox setup from the settings section from the events calendar:
http://luisne.kuglerdesign.com/wp-content/uploads/2016/02/donation-checkbox-screenshot.jpgIf you need any other information please ask!
I bet it is just one small thing I am missing to get it to work though, and would be very grateful for any help you can give me!
Thank You,
AindreasFebruary 3, 2016 at 7:28 am #1067005BarryMemberHi Aindreas,
Both the code and the screenshot of additional field settings you shared look fine to me (and if I reverse the process and copy what you shared – it again works for me locally) – so unfortunately I’m a little unsure as to why it’s failing in your case.
Can you point me to an event for which you set Donation to Yes? I went through the first two pages of events listed on your /events/list/ page but was unable to identify any that had Donation set to Yes (unless you’ve modified your templates to hide it, I’d expect to see this information in the grey ‘meta’ area of one of the events in question).
Thanks!
February 4, 2016 at 2:56 pm #1067903BarryMemberHi Aindreas,
Just checking in here as some gremlins in our forum software may have caused you some problems if you tried to reply yesterday.
How are things coming along?
February 5, 2016 at 1:38 am #1067997AindreasParticipantHi Barry,
I didnt post anything yesterday, but thanks for asking!
Ive added the donation option to the events ‘W. B. Yeats – The story of his family and friends’ and ‘Silent Prayer’.
I just got a feeling that because I created my own events list file in my child theme it might be affecting it if it is working on yours. I pasted the code at: http://pastebin.com/vtcmBCEq – the file is named ‘single-event.php’.
Again, thank you for all your time so far!
Kind Regards,
AindreasFebruary 5, 2016 at 7:56 am #1068285BarryMemberHmm, not seeing anything there that would obviously conflict, but unless I was looking at the wrong WB Yeats event (is there more than one?) something still doesn’t feel right.
Ordinarily, with an additional field like the one we discussed in place, I’d expect to see something along these lines in the grey meta area:
This is notable by its absence on the WB Yeats event/any of your events, which is why I wanted to double check if you either had customizations in place or if you were certain you had supplied a value for that field.
Ultimately … I’m sorry we’ve not been able to get you on track here, but since this is really a customization task we may need to bail out at this point and leave it in your hands – as the suggested solution does seem to work as expected on a clean test site.
February 8, 2016 at 10:12 am #1069623AindreasParticipantWell, thank you for all your time Barry! I really do appreciate it. Shame it didnt work, but I guess Ill find out why not eventually.
Is there maybe an article you could send me a link to for working with those custom fields?
Thanks Again!
Kind Regards,
AindreasPS: maybe leave this ticket open and if I do find the reason its not working I will post it here
February 8, 2016 at 11:16 am #1069661BarryMemberIs there maybe an article you could send me a link to for working with those custom fields?
Sure, we’ve got this:
theeventscalendar.com/knowledgebase/pro-additional-fields
PS: maybe leave this ticket open and if I do find the reason its not working I will post it here
Sounds good (though do note topics are automatically closed after two weeks by our support droid, but of course you can always create a fresh topic and post your findings there – and simply link to this one).
February 15, 2016 at 10:36 am #1073364AindreasParticipantHello again Barry,
I have a little question regarding this issue. I have been doing some work on it and was able to display all the metadata for the event next to the event list. However, I am having trouble singling out the correct part of the metadata I require.
My question is this:
Could you send me the location of the file where the metadata content for a specific event is decided?
– I have been searching through a lot of files but I feel it is like looking for a needle in a haystack, if you could point me in the right direction I would be very grateful!Kind Regards,
AindreasFebruary 15, 2016 at 11:08 am #1073373BarryMemberHi Aindreas,
In terms of which template renders the additional fields, it is the following Events Calendar PRO template:
pro/modules/meta/additional-fields.php
If you are asking where the list of names and values comes from, it’s from a call to tribe_get_custom_fields() made in:
Tribe__Events__Pro__Single_Event_Meta::additional_fields()
The above class is located in src/Tribe/Single_Event_Meta.php within the Events Calendar Pro plugin directory.
March 1, 2016 at 8:35 am #1083908Support DroidKeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Add Custom text to Price in Upcoming Events List’ is closed to new replies.