Appointments+ service location field needed in confirmation email

On Appointments+ in the confirmation email I want to include the location of the service for the client to know where to go for the appointment. I can't figure out which field to use. Is this possible?

  • Vaughan
    • Support/SLS MockingJay

    Hi @vasu,

    This isn't currently possible, it would require a bit of custom coding.

    I'm not sure if it's as simple as adding $r->location to the wp_mail() function & then adding location to the conversion script. It might be a bit more complicated than that.

    Let me just ask a developer if he can give you any ideas on this.

    I will also add this to the feature requests for the developer to look at including in a future release.

    Hope this helps

  • Hoang Ngo
    • Code Slayer

    Hi there @Vasu,

    For archive this, firstly please go to Setting->General tab. Find the Confirmation email Message and update the text "LOCATION" to the place you want the text "Location: your address" display.

    And then, please copy this code to your theme functions.php

    global $appointments;
    if ( $appointments instanceof Appointments ) {
    	add_filter( 'app_confirmation_message', 'test', 10, 2 );
    	function test( $msg, $obj ) {
    		if ( property_exists( $obj, 'location' ) ) {
    			$locations = get_option( 'app_locations_data' );
    			foreach ( $locations as $value ) {
    				if ( $obj->location == $value['id'] ) {
    					$msg = str_replace( 'LOCATION', 'Location: ' . $value['address'], $msg );
    					return $msg;
    				}
    			}
    		}
    	}
    }

    If you have any issues please don't hesitate to let us know so we can assist

    Best Regards
    Hoang

  • Hoang Ngo
    • Code Slayer

    Hi @ulir,

    I hope you are well today and thanks for your question.

    In that case, please add the text "LOCATION" to your Reminder email Message. And modify the code you already added to this

    global $appointments;
    if ( $appointments instanceof Appointments ) {
    	add_filter( 'app_confirmation_message', 'append_location_to_app_email', 10, 2 );
    add_filter( 'app_reminder_message', 'append_location_to_app_email', 10, 2 );
    	function append_location_to_app_email( $msg, $obj ) {
    		if ( property_exists( $obj, 'location' ) ) {
    			$locations = get_option( 'app_locations_data' );
    			foreach ( $locations as $value ) {
    				if ( $obj->location == $value['id'] ) {
    					$msg = str_replace( 'LOCATION', 'Location: ' . $value['address'], $msg );
    					return $msg;
    				}
    			}
    		}
    	}
    }

    Please give it a try and let see if it help :slight_smile:

    Best Regards,
    Hoang

  • ulir
    • Site Builder, Child of Zeus

    Hi there,

    this is very strange!
    I changed the code to the one given above, it didn't work for me.
    Then I changed it back to the first code which was working fine until yesterday but that one doesn't work anymore either?
    As soon as I add the codes to the function.php, I don't receive any confirmation email. As soon as I delete the code, I receive the confirmation email but without the location :slight_frown:.

  • Saurabh
    • New Recruit

    Hi there!

    If you are getting no email, I'm guessing that the location is not properly set. I've modified the code to account for that

    global $appointments;
    
    if ( $appointments instanceof Appointments ) {
    	add_filter( 'app_confirmation_message', 'append_location_to_app_email', 10, 2 );
    	add_filter( 'app_reminder_message', 'append_location_to_app_email', 10, 2 );
    	function append_location_to_app_email( $msg, $obj ) {
    		if ( property_exists( $obj, 'location' ) ) {
    			$locations = get_option( 'app_locations_data' );
    			foreach ( $locations as $value ) {
    				if ( $obj->location === $value['id'] ) {
    					$msg = str_replace( 'LOCATION', 'Location: ' . $value['address'], $msg );
    				}
    			}
    		}
    		return $msg;
    	}
    }

    Let us know what happens when you use this code. If the location isn't set, you should get an email, with the LOCATION text unchanged.

    If that is the case, please check if the locations are indeed set correctly for the appointment.

    Best

    Saurabh

  • ulir
    • Site Builder, Child of Zeus

    Hi Saurabh,

    I'm feeling quite stupid right now...
    Of course we tested with the only two experts left who didn't have a location set!
    I just received my confirmation email, the reminder email will hopefully arrive tomorrow :slight_smile:.

    THANK YOU!

  • Saurabh
    • New Recruit

    Hi!

    No issues. If that is the case, hopefully things will work just fine.

    Do let us know if they don't. we'll be more than happy to help.

    In any case, use this new code since it'll be easier to diagnose errors, if any.

    Best

    Saurabh

  • ulir
    • Site Builder, Child of Zeus

    Hi again,

    I just used the new code and I only get "LOCATION" in my confirmation email (appointments1.png), even though the location is set now.

    When I use the code from before, I get this message (appoinments2.png)
    This one is working, I just get "Ort: Location:" in the message, it should only be "Ort:"

    Best Regards
    Uli

  • Saurabh
    • New Recruit

    Hi,

    In that case, you can remove the Location: string from the function and use it like this:

    global $appointments;
    if ( $appointments instanceof Appointments ) {
    	add_filter( 'app_confirmation_message', 'append_location_to_app_email', 10, 2 );
    add_filter( 'app_reminder_message', 'append_location_to_app_email', 10, 2 );
    	function append_location_to_app_email( $msg, $obj ) {
    		if ( property_exists( $obj, 'location' ) ) {
    			$locations = get_option( 'app_locations_data' );
    			foreach ( $locations as $value ) {
    				if ( $obj->location == $value['id'] ) {
    					$msg = str_replace( 'LOCATION', $value['address'], $msg );
    					return $msg;
    				}
    			}
    		}
    	}
    }

    Best

    Saurabh

  • Knudoboy
    • Design Lord, Child of Thor

    Well well. Along these lines, I wonder if it will be possible to include the contact info of the service provider (phone, email) in the confirmation mail. The data listed under the user tab in WP, is what I need. My clients might want to tailor the service according to their needs.
    Also, if a picture of the service provider could be included in the confirmation mail, it would be great (the gravatar image possibly?)

  • Ivan
    • HummingBird

    Hey Knudoboy.

    Thanks for posting in this thread, however it might be best if you open your own, even if the issues seem closely related. That way it will remain independent of this one and ensure it doesn't confuse issues here if this thread needs reopening again by the author.

    Posting on old threads can also lead to us missing your questions.

    It also means the member who started this thread or anyone following it isn't inundated with post notifications each time we respond to each other. A lengthy thread could annoy the original thread starter

    This also allows us to better track and answer your questions to ensure we don't miss any for ya.

    If the current thread is relevant then please feel free to link back to this in your new one.

    You can start a new thread here:

    https://premium.wpmudev.org/forums/#question

    Thanks,
    Ivan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.