Conditional Logic For Appointment+

Is there a way to apply a conditional logic to Appointment+. I have 2 options for New and Returning Clients. One of the custom fields under Confirm Appointment Details for New Clients is "Do you have a preferred location". This allows Company to validate/confirm client appointment. Returning Clients ere however able to select a specific Service Location, in which chase the "Do you have a preferred location" becomes redundant ask in Confirmation details. Is there any way to remove that field if a specific Service Location is chosen. There are four Service locations. Working offline so can't share site but any direction appreciated.

Thx

  • Adam Czajczyk

    Hello daleh009,

    I hope you're well today and thank you for your question!

    This currently is not supported by Appointments+ "out of the box". I think though that there's a chance that it could be achieved with a bit of customization. Please note that I'm not able to guarantee that to you yet but I'll be glad to take a look.

    I would however like to ask first:

    - the "first time" customer has to select preferred location, that's understandable;
    - in case of returning customer tho, is it that the location "doesn't matter" or should the location chosen with "first time booking" be used?
    - the "returning customer" is always a "logged in user" I presume?

    Let me know please!
    Best regards,
    Adam

  • daleh009

    Adam, thanks for quick response. I am still debating whether to force clients to register before making an appointment, but let me know your thoughts based on my ask.

    To respond to your questions - the first time client is asked to Select a Service Offering and a Dummy Provider is automatically chosen regardless of Service selected. In the Appt. Confirmation Details, client is prompted for a "Preferred Location" entry. As far as the returning client, it will first ask him to select one of four Service Locations. Once selected, it will identify Providers for that specific location, so they have ability to select Provider of their choice. Once they get to Appt. Confirmation Details, it will prompt again for "Preferred Location". So I was looking to see if I could apply some logic to either override, hide or blank that entry from being used redundantly. Alternatively, if I can automatically populate that field with the Location chosen, I think that should be fine. Hope this helps.

    Thx again.

  • Predrag Dubajic

    Hi daleh009,

    Thanks for the additional info, I had a look at this and discussed it with one of our developers and it doesn't seem like an easy task but it should be doable with some additional coding.

    I have created report for our second level support dev guys so they can have a closer look and see what would could be done here.
    Please note that, developer response might be slower than usual staff response, so we appreciate your patience on this.

    Best regards,
    Predrag

  • Panos

    Hi daleh009 ,

    In order to do this without modifying plugin file is by hooking in the app_additional_fields filter.

    Unfortunately this doesn't allow to check what fields to add or not, so we can only modify the string of the output. Therefor we need to know the exact string we need to remove, that's not that hard, all you need to do is to use your browser's inspector and copy the text from there.

    Here is an example I tried out in my test site:

    function wpmudev_app_additional_fields( $form ){
    
    	$replace_input = "<div class='appointments-field appointments-howheardaboutus-field'><label for=\"appointments-howheardaboutus1924153357ee6435e9f4b4a3acad46d1\"><span>How you heard about us</span></label><input type='text' id='appointments-howheardaboutus1924153357ee6435e9f4b4a3acad46d1' class='appointments-field-entry appointments-howheardaboutus-field-entry' data-name='additional_fields[howheardaboutus]' value='' /></div>";
    
    	if( is_user_logged_in() )
    		$replace_input = "<div class='appointments-field appointments-commando-field'><label for=\"appointments-commandod36887c4a45b7d09c504b9523f81e4e1\"><span>Commando</span></label><input type='checkbox' id='appointments-commandod36887c4a45b7d09c504b9523f81e4e1' class='appointments-field-entry appointments-commando-field-entry' data-name='additional_fields[commando]' value='1' /></div>";
    
    	$form = str_replace( $replace_input, '', $form );
    
    	return $form;
    
    }
    
    function wpmudev_app_additional_fields_action(){
    	add_filter( 'app_additional_fields', 'wpmudev_app_additional_fields', 10, 1 );
    }
    
    add_action( 'init', 'wpmudev_app_additional_fields_action' );

    All you need to do is replace the content of the $replace_input variable with the corresponding text you copied from your browser and then add the snippet at your theme's functions.php or a mu-plugin.

    In case you find this out of your comfort zone I would be happy to do this for you. In such case please provide admin and ftp information. You can send that privately through our contact form: https://premium.wpmudev.org/contact/

    Select "I have a different question?" for your topic - this and the subject line ensure that it gets assigned to me.

    Send in:Subject: "Attn: Panos Lyrakis"

    - Admin login:
    Admin username
    Admin password
    Login url

    - FTP credentials
    host
    username
    password
    (and port if required)

    - link back to this thread for reference

    Thanks!
    Panos

    • daleh009

      Panos, thanks for the code snippet. I added to my child theme functions.php but I got an error:
      (Parse error: syntax error, unexpected 'appointments' (T_STRING) on the line I added for the $replace_input variable. here is the syntax of the variable from browser inspect that I copied.

      <div class="appointments-field appointments-doyouhaveapreferredlocation-field"><label for="appointments-doyouhaveapreferredlocationa631dd431d2df0da8986d35b49641b06"><span>Do you have a preferred location?</span></label><input id="appointments-doyouhaveapreferredlocationa631dd431d2df0da8986d35b49641b06" class="appointments-field-entry appointments-doyouhaveapreferredlocation-field-entry" data-name="additional_fields[doyouhaveapreferredlocation]" value="" type="text"></div>

      I even tried it without the type="text" to match your snippet but same error. Do I have to modify the 2nd entry for the $replace_input variable which references type="checkbox"? Not sure if I am I supposed to leave line as is or modify as well. Please advise.

      Unfortunately I am using DesktopServer to develop site offline, so no link to share at this time.

      Thx.

  • daleh009

    Here's debug output from DS -

    Call Stack
    # Time Memory Function Location
    1 0.0022 296920 {main}( ) ../index.php:0
    2 0.0026 299776 require( '/Users/myname/Documents/Websites/www.mysite.dev/wp-blog-header.php' ) ../index.php:17
    3 0.0029 317224 require_once( '/Users/myname/Documents/Websites/www.mysite.dev/wp-load.php' ) ../wp-blog-header.php:13
    4 0.0035 326864 require_once( '/Users/myname/Documents/Websites/www.mysite.dev/wp-config.php' ) ../wp-load.php:39
    5 0.0046 432792 require_once( '/Users/myname/Documents/Websites/www.mysite.dev/wp-settings.php' ) ../wp-config.php:81

  • Panos

    Hi daleh009 ,

    Thanks for you feedback! The truth is it requires some tweaking in order to make it work properly. Would you mind sending me admin and ftp credentials so I can have a closer look at this? You can send that privately through our contact form: https://premium.wpmudev.org/contact/

    Select "I have a different question?" for your topic - this and the subject line ensure that it gets assigned to me.

    Send in:Subject: "Attn: Panos Lyrakis"

    - Admin login:
    Admin username
    Admin password
    Login url

    - FTP credentials
    host
    username
    password
    (and port if required)

    - link back to this thread for reference

    Kind regards!
    Panos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.