Not update the description on google calendar

Hi!

The latests versions of plugin, no update the description on google calendar when i edit the appointment on the wordpress.

Thanks

  • Luís

    Hi Arturo ,

    Hope you're doing well today!

    After spoke with the developer, this feature was changed in the previous versions of Appointments+, because some users didn't want to change the GCal description.

    The description will be set on event creation following the structure in Appointments > Settings > Google Calendar. There are people that use GCal to add their own notes so we don't want to overwrite those notes once the event was created.

    However, I already pinged the developer to see if is possible to add some custom code to get back this feature.

    Cheers, Luís

  • Arturo

    Goodnight,

    I feel very bad that a functionality that is used, it is removed from one version to another without notifying users.

    I think if it is a function that was active, it should have set a variable in the general configuration to update (or not) for descriptions Gcal, for example my client uses mainly the web and then combined with Gcal and is absolutely necessary have the updated descriptions.

    I hope to resolve this soon, because I think it's a pretty big mistake and apply these decisions without users who use it is an even bigger mistake.

    Thanks.

  • Luís

    Hi Arturo ,

    Hope you're doing well today!

    New hooks were added to this new version of Appointments +. However, to change the GCal description, can you try add this code to your theme functions.php:

    add_filter( 'appointments_gcal_update_event', 'app_hooks_update_gcal_event_description', 10, 2 );
    function app_hooks_update_gcal_event_description( $event, $appointment ) {
        $event->setDescription( $appointment->note );
        return $event;
    }

    Cheers, Luís

  • Panos

    Hi Arturo ,

    Of what I understand you need to add the two last custom fields you nenthion above:
    Semanas de embarazo: FIELD_SEMANASDEEMBARAZO
    Paquete/Promoción elegid@: FIELD_PAQUETEPROMOCINSELECCIOND

    These are user meta fields right?

    Please try adding the following snippet in your functions.php file:

    add_filter( 'app-gcal-set_description', 'wpmudev_app_gcal_set_description', 10, 2 );
    
    function wpmudev_app_gcal_set_description( $content, $app ){
    
    	if ( is_user_logged_in() ) {
    		$user_id = get_current_user_id();
    		$FIELD_SEMANASDEEMBARAZO = get_user_meta( $user_id, 'FIELD_SEMANASDEEMBARAZO', true );
    		$FIELD_PAQUETEPROMOCINSELECCIOND = get_user_meta( $user_id, 'FIELD_PAQUETEPROMOCINSELECCIOND', true );
    
    		$content .= 'Semanas de embarazo: ' . $FIELD_SEMANASDEEMBARAZO . '
    Paquete/Promoción elegid@: ' . $FIELD_PAQUETEPROMOCINSELECCIOND;
    	}
    
    	return $content;
    }

    and let us know how it goes :slight_smile:

    Thanks!
    Panos

  • Arturo

    My code desired:

    add_filter( 'appointments_gcal_update_event', 'app_hooks_update_gcal_event_description', 10, 2 );
    
    function app_hooks_update_gcal_event_description( $event, $appointment ) {
    
        $fecha = mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),$appointment->start);
    
        $event->setDescription( "Cliente: ".$appointment->name."\n".
                                "Teléfono: ".$appointment->phone."\n".
                                "Lugar de la Cita: ".$appointment->get_service_name( $appointment->service )."\n".
                                "Fecha/Hora: ".$fecha."\n".
                                //THE PROBLEMS IS HERE:
                                "Semanas de Embarazo: ".$FIELD_PAQUETEPROMOCINSELECCIOND."\n".
                                "Paquete/Promoción elegid@: ".$FIELD_PAQUETEPROMOCINSELECCIOND);
    
        return $event;
    }

    With the code:

    add_filter( 'app-gcal-set_description', 'wpmudev_app_gcal_set_description', 10, 2 );
    
    function wpmudev_app_gcal_set_description( $content, $app ){
    
    	if ( is_user_logged_in() ) {
    		$user_id = get_current_user_id();
    		$FIELD_SEMANASDEEMBARAZO = get_user_meta( $user_id, 'FIELD_SEMANASDEEMBARAZO', true );
    		$FIELD_PAQUETEPROMOCINSELECCIOND = get_user_meta( $user_id, 'FIELD_PAQUETEPROMOCINSELECCIOND', true );
    
    		$content .= 'Semanas de embarazo: ' . $FIELD_SEMANASDEEMBARAZO . '
    Paquete/Promoción elegid@: ' . $FIELD_PAQUETEPROMOCINSELECCIOND;
    	}
    
    	return $content;
    }

    Not work for me.

    Thanks

  • Panos

    Hey Arturo ,

    I'm still not sure how you are setting these two variables:

    $FIELD_SEMANASDEEMBARAZO and $FIELD_PAQUETEPROMOCINSELECCIOND

    I have replaced the rest in the following snippet:

    add_filter( 'app-gcal-set_description', 'wpmudev_app_gcal_set_description', 10, 2 );
    
    function wpmudev_app_gcal_set_description( $content, $app ){
    
    	global $appointments;
    
    	//$FIELD_SEMANASDEEMBARAZO = '????';
    	//$FIELD_PAQUETEPROMOCINSELECCIOND = '????';
    	$fecha = mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),$app->start);
    
    	$content .= 'Cliente: ' . $app->name . '
    Teléfono: ' . $app->phone . '
    Lugar de la Cita: ' .$appointments->get_service_name( $app->service ). '
    Fecha/Hora: '.$fecha .'
    Semanas de embarazo: ' . $FIELD_SEMANASDEEMBARAZO . '
    Paquete/Promoción elegid@: ' . $FIELD_PAQUETEPROMOCINSELECCIOND;
    
    	return $content;
    
    }

    Could you please provide some information regarding the two variables I mentioned in the beginning of my reply? In the meantime you can try this code (by settings some dummy text for the two vars) and see if it does what you require!

    Thanks!
    Panos

  • Panos

    You mean custom fields in user's meta? Can they be retrieved with:
    get_user_meta( $user_id, 'FIELD_SEMANASDEEMBARAZO', true )?

    If so, you can try the following snipped:

    add_filter( 'app-gcal-set_description', 'wpmudev_app_gcal_set_description', 10, 2 );
    
    function wpmudev_app_gcal_set_description( $content, $app ){
    
    	global $appointments;
    
    	$fecha = mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),$app->start);
    
    	$content .= 'Cliente: ' . $app->name . '
    Teléfono: ' . $app->phone . '
    Lugar de la Cita: ' .$appointments->get_service_name( $app->service ). '
    Fecha/Hora: '.$fecha;
    
    	if ( is_user_logged_in() ) {
    		$user_id = get_current_user_id();
    		$FIELD_SEMANASDEEMBARAZO = get_user_meta( $user_id, 'FIELD_SEMANASDEEMBARAZO', true );
    		$FIELD_PAQUETEPROMOCINSELECCIOND = get_user_meta( $user_id, 'FIELD_PAQUETEPROMOCINSELECCIOND', true );
    
    		$content .= '
    Semanas de embarazo: ' . $FIELD_SEMANASDEEMBARAZO . '
    Paquete/Promoción elegid@: ' . $FIELD_PAQUETEPROMOCINSELECCIOND;
    
    	}
    
    	return $content;
    
    }

    Thanks!
    Panos

  • Panos

    Perhaps I understood wrong :slight_smile:

    Have you enabled the Additional Fields add on and these are additional fields that user fills in when making a booking?

    I think this is more correct then :

    add_filter( 'app-gcal-set_description', 'wpmudev_app_gcal_set_description', 10, 2 );
    
    function wpmudev_app_gcal_set_description( $content, $app ){
    
    	global $appointments, $wpdb;
    
    	$app_id = $app->ID;
    
    	$app_meta_fields_res = $wpdb->get_row( "SELECT meta_value FROM {$wpdb->prefix}app_appointmentmeta WHERE app_appointment_id={$app_id} AND meta_key='additional_fields'" );
    
    	$app_meta_fields = isset( $app_meta_fields_res->meta_value ) ? unserialize($app_meta_fields_res->meta_value) : array();
    
    	$fecha = mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),$app->start);
    
    	$content .= 'Cliente: ' . $app->name . '
    Teléfono: ' . $app->phone . '
    Lugar de la Cita: ' .$appointments->get_service_name( $app->service ). '
    Fecha/Hora: '.$fecha;
    
    	if( !empty( $app_meta_fields ) ){
    
    		foreach( $app_meta_fields as $key => $val ){
    
    			$content .='
    ' . $key . ': ' . $val;
    
    		}
    
    	}
    
    	return $content;
    }

    Thanks!
    Panos

  • Arturo

    Hi Panos,

    I think it's best to get in history.

    The problem starts when I update a appointment (on the wp-admin), since the description of the google calendar is not updated.

    In the latest version, they created a new event:

    app_hooks_update_gcal_event_description

    Currently with this function, I update all the data I need (those established in the description of google calendar when a new appointment):

    add_filter( 'appointments_gcal_update_event', 'app_hooks_update_gcal_event_description', 10, 2 );
    
    function app_hooks_update_gcal_event_description( $event, $appointment ) {
    
        $fecha = mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),$appointment->start);
    
        $event->setDescription( "Cliente: ".$appointment->name."\n".
                                "Teléfono: ".$appointment->phone."\n".
                                "Lugar de la Cita: ".$appointment->get_service_name( $appointment->service )."\n".
                                "Fecha/Hora: ".$fecha."\n".
                                "Notas: ".$appointment->note);
                                //"Semanas de Embarazo: ".$FIELD_SEMANASDEEMBARAZO."\n".
                                //"Paquete/Promoción elegid@: ".$FIELD_PAQUETEPROMOCINSELECCIOND);
        return $event;
    }

    The problem is that I need to get the FIELD_SEMANASDEEMBARAZO and FIELD_PAQUETEPROMOCINSELECCIOND variables corresponding to two macros of two custom fields (like emails notifications).

    I've tried your last code and does not work, I think the problem is in the event and the parameters you use, if you look at the current function are different.

    Thanks!

  • Arturo

    Hi,

    I write the solution;

    add_filter( 'appointments_gcal_update_event', 'app_hooks_update_gcal_event_description', 10, 2 );
    
    function app_hooks_update_gcal_event_description( $event, $appointment ) {
    
       global $wpdb;
       $app_id = $appointment->ID;
    
       $app_meta_fields_res = $wpdb->get_row( "SELECT meta_value FROM {$wpdb->prefix}app_appointmentmeta WHERE app_appointment_id={$app_id} AND meta_key='additional_fields'" );
       $app_meta_fields = isset( $app_meta_fields_res->meta_value ) ? unserialize($app_meta_fields_res->meta_value) : array();
    
        if( !empty( $app_meta_fields ) ){
    
                    foreach( $app_meta_fields as $key => $val ){
                            switch ($key) {
                             case "semanasdeembarazo":
                                $FIELD_SEMANASDEEMBARAZO = $val;
                                break;
                             case "paquetepromocinselecciond":
                                $FIELD_PAQUETEPROMOCINSELECCIOND = $val;
                                break;
                            }
                    }
    
            }
    
        $fecha = mysql2date( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ),$appointment->start);
    
        $event->setDescription( "Cliente: ".$appointment->name."\n".
                                "Teléfono: ".$appointment->phone."\n".
                                "Lugar de la Cita: ".$appointment->get_service_name( $appointment->service )."\n".
                                "Fecha/Hora: ".$fecha."\n".
                                //"Notas: ".$appointment->note);
                                "Semanas de Embarazo: ".$FIELD_SEMANASDEEMBARAZO."\n".
                                "Paquete/Promoción elegid@: ".$FIELD_PAQUETEPROMOCINSELECCIOND);
        return $event;
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.