Skip Navigation

[Resolved] Comparation date

This support ticket is created 6 years, 2 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 15 replies, has 5 voices.

Last updated by Minesh 6 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1104267

Minesh
Supporter

Languages: English (English )

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

Well - I've added following shortcode to your current theme's functions.php file:


function func_display_status() {
	global $post;   
	static $j = 0;  
$a = shortcode_atts( array(
  'format' => 'U'
  ), $atts );
  
  
    /*calculating booking deadline */ 
	$days_release = get_post_meta( $post->ID, 'wpcf-release', true );
	$convert_release = ($days_release * 24 * 60 * 60); 
	
	/* getting partenze value */
	$date_partenza = get_post_meta( $post->ID, 'wpcf-partenze');
	$partenze = $date_partenza[$j];
	
	/* geting actual deadline */
	$deadline = ($partenze - $convert_release); 
	
	$j = $j+1;
	if($partenze <= time()){
		return "Closed";
	}else if ($partenze > time() and $deadline < time()){
		return "On request";
	}else if ($partenze > time() and $deadline > time()){
		return "Open";
	}else if ($deadline <= time()){
		return "Last Day";
	}

}
add_shortcode('show_status', 'func_display_status');

As you can see its using $deadline and $partenze fields.

You should use above shortcode as [show_status] wherever you want to display the status.

- if [partenze] is equal to [today] = Close
==> OK - its covered
- if [booking-deadline] is equal to [today] = Last day
==> Ok - its covered
- if [partenze] is lower then [today] and [booking-deadline] is lower then [today]= Close
==> No need for this conditions as [partenze] is lower then [today] we want to display the status = Close.
- if [partenze] is greater then [today] and [booking-deadline] is lower then [today]= On request
=> OK - its covered
- if [partenze] is greater then [today] and [booking-deadline] is greater then [today]= Open
==> Ok, its covered.