Skip Navigation

[Resuelto] Comparation date

This support ticket is created hace 6 años, 3 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 15 respuestas, tiene 5 mensajes.

Última actualización por Minesh hace 6 años, 2 meses.

Asistido por: Minesh.

Autor
Mensajes
#1104267

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: 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.