I was the one who submitted this ticket: https://toolset.com/forums/topic/condition-based-on-time/ and it worked out great.
Now I am trying to make it so that on December 25 (for example) it says we're closed bypassing the other conditionals that are present.
This is what I have in my view now:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-conditional if="( '[new_time tz="America/New_York"]' gte '2' ) AND ( '[new_time tz="America/New_York"]' lt '10.9999' )"]We're Closed[/wpv-conditional]
[wpv-conditional if="( '[new_time tz="America/New_York"]' gte '11' ) AND ( '[new_time tz="America/New_York"]' lt '24' )"]We're Open[/wpv-conditional]
[wpv-conditional if="( '[new_time tz="America/New_York"]' gte '0' ) AND ( '[new_time tz="America/New_York"]' lt '1.9999' )"]We're Open[/wpv-conditional]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"][/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]
Dear donald,
It needs custom codes, for example, you can try this:
1) add below codes into your theme/functions.php:
function new_time_2( $atts ) {
$timezone_string = '';
if ( isset( $atts['tz'] ) ) {
$tz = $atts['tz'];
if ( ( is_string( $tz ) ) && ( !empty( $tz ) ) ) {
$timezone_string = $tz;
}
}
if ( !empty ( $timezone_string ) ) {
$reset_timezone = date_default_timezone_get();
date_default_timezone_set( $timezone_string );
$res = date('F j');
date_default_timezone_set( $reset_timezone );
}
return $res;
}
add_shortcode( 'new_time_2', 'new_time_2' );
2) Dashboard-> Toolset-> Settings-> Front-end Content
option "Third-party shortcode arguments" add the shortcode name "new_time_2",
3) Use above shortcode in your content like this:
[wpv-conditional if="('[new_time_2 tz="America/New_York"]' eq 'December 22' ) " ]We're Open[/wpv-conditional]
That worked great but can it override the other conditionals so that it doesn't show "We're Open and We're Closed" during the normal operating hours?
You can try this:
1) Create a content template "normal-days", with below codes:
[wpv-conditional if="( '[new_time tz="America/New_York"]' gte '2' ) AND ( '[new_time tz="America/New_York"]' lt '10.9999' )"]We're Closed[/wpv-conditional]
[wpv-conditional if="( '[new_time tz="America/New_York"]' gte '11' ) AND ( '[new_time tz="America/New_York"]' lt '24' )"]We're Open[/wpv-conditional]
[wpv-conditional if="( '[new_time tz="America/New_York"]' gte '0' ) AND ( '[new_time tz="America/New_York"]' lt '1.9999' )"]We're Open[/wpv-conditional]
2) Modify the shortcode in Views loops as below:
[wpv-conditional if="('[new_time_2 tz="America/New_York"]' eq 'December 22' ) " debug="true"]We're Open[/wpv-conditional]
[wpv-conditional if="('[new_time_2 tz="America/New_York"]' eq 'December 22' ) " evaluate="false" debug="true"][wpv-post-body view_template="normal-days"][/wpv-conditional]
More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional
evaluate (opt): true | false
It can be set to true or false and controls whether we want the condition to be met or not. The default value is true.
I had this showing where it was suppose to show something else.
I just test it in my localhost, it works fine, if you more assistance for it, please duplicate same problem in a test site, and fill below private detail box with login details, also point out the problem page URL, and where I can edit you codes, I need a live website to test and debug. thanks