Skip Navigation

[Resolved] Need help displaying content based on the event start date

This support ticket is created 6 years, 6 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 3 voices.

Last updated by Noman 6 years, 5 months ago.

Assisted by: Noman.

Author
Posts
#574885
Screen Shot 2017-09-29 at 9.01.24 AM.jpg

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: hidden link

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]

I'm not sure what I'm doing wrong here.

#574951

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#575461

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Josh,

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:
hidden link

1. I have added this code in your theme’s or child theme’s functions.php file:

function event_start_date_timestamp_func($atts) {
	$a = (shortcode_atts(array(
	    'id' => '',
   ), $atts));
   $event_date = get_post_meta($a['id'], '_EventStartDate', true);
   $event_date_timestamp = strtotime($event_date);
   return $event_date_timestamp;
}
add_shortcode('event_start_date_timestamp', 'event_start_date_timestamp_func');

2. And then updated the condition in the Content Template like this:

[wpv-conditional if="( [event_start_date_timestamp id='[wpv-post-id]'] gt NOW() ) AND ( NOT(empty($(wpcf-webinar-product-id)) )"][wpv-view name="webinar-purchase" ids="[types field='webinar-product-id' format='FIELD_VALUE'][/types]"][/wpv-conditional]

I hope its working good now, please check and let me know. Thank you

#575485

Hi Noman,

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: hidden link 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: hidden link

Here is a link to an event in the future: hidden link

Thanks for the continued help! Let me know if you need more info.

Josh

#575501

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

I have made updates to the condition and I believe its working good now:

Past event: hidden link

Future event: hidden link

Main Webinars page: hidden link

[wpv-conditional if="( [event_start_date_timestamp id='[wpv-post-id]'] gt NOW() ) AND ( [types field='webinar-product-id'][/types] ne '' )"][wpv-view name="webinar-purchase" ids="[types field='webinar-product-id' format='FIELD_VALUE'][/types]"][/wpv-conditional]

Thank you

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.