[Résolu] Need help displaying content based on the event start date
This support ticket is created Il y a 7 années et 2 mois. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
I am trying to: Conditionally hide and display content based on the event start date.
Link to a page where the issue can be seen: lien caché
I expected to see: the block that displays the price and add to cart button hidden.
Instead, I got: The block is still displayed
I'm using Modern Tribe Events Calendar and I'm wanting to hide the buy button on events that have started or passed. I've enabled the _EventStartDate and _EventEndDate custom fields and am using the following conditional statement but it's not working.
[wpv-conditional if="( $(_EventStartDate) gt NOW() ) AND ( $(wpcf-webinar-product-id) ne '' )"][wpv-view name="webinar-purchase" ids="[types field='webinar-product-id' format='FIELD_VALUE'][/types]"][/wpv-conditional]
Hello. Thank you for contacting the Toolset support.
Well - Events calendar store '_EventStartDate' as date string. I think you should create a custom shortcode and convert your date string to timestamp and return timestamp to compare with Now() function.
If you do not know how to do this, I would happy to help you further. I need problem URL and access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
Thank you for providing login info. Minesh is having a holiday today, I am going to take over this ticket. I have made some updates please check page now: lien caché
1. I have added this code in your theme’s or child theme’s functions.php file:
Thanks for jumping in to help in Minesh's absence.
I took a look at the end result and for some reason it's not quite working correctly. If you want to take a look, you can visit the webinars calendar here: lien caché and view the results in the "month" view. From there you can choose any event in the past and any event in the future and see that while those in the past are not displaying the price and add-to-cart button, neither are those in the future.
Here is a link to an event in the past: lien caché
Here is a link to an event in the future: lien caché
Thanks for the continued help! Let me know if you need more info.