Appointments+ Default to Select Service

Hello Gents,

Back on Mon Jun 16 2014, 1:05:12 PM, a support ticket was posted and resolved for various issues.

[Original Support Ticket below]
(https://premium.wpmudev.org/forums/topic/appointments-default-to-please-select-for-service?npp=b&utm_expid=3606929-81.6_x2aktJQ2qbOSnTRGna0w.1&utm_referrer=https%3A%2F%2Fwww.google.com%2F)

I'm really interested in the response by Ash who gave some php code to force the Appointments+ Plugin Service Dropdown menu to read "Select Service" instead of having the drop down box default to the first listed Service in the Admin backend section. However, his instructions specify to do the following:

[from Ash]
Would you please go to
/plugins/appointments/includes/class_app_shortcodes.php line no 1199 to 1225 and replace

$s .= '<option selected="selected" value="">Please select</option>';
if ( $services ) {
foreach ( $services as $service ) {
$service_description = '';
// Check if this is the first service, so it would be displayed by default
if ( isset( $_REQUEST['app_service_id'] ) && $service->ID == $appointments->service ) {
$d = '';
$sel = ' selected="selected"';
}
else {
$d = ' style="display:none"';
$sel = '';
}
// Add options
$s .= '<option value="'.$service->ID.'"'.$sel.'>'. stripslashes( $service->name ) . '</option>';
// Include excerpts
$e .= '<div '.$d.' class="app_service_excerpt" id="app_service_excerpt_'.$service->ID.'" >';
// Let addons modify service page
$page = apply_filters( 'app_service_page', $service->page, $service->ID );
switch ( $description ) {
case 'none' : break;
case 'excerpt' : $service_description .= $appointments->get_excerpt( $page, $thumb_size, $thumb_class, $service->ID ); break;
case 'content' : $service_description .= $appointments->get_content( $page, $thumb_size, $thumb_class, $service->ID ); break;
default : $service_description .= $appointments->get_excerpt( $page, $thumb_size, $thumb_class, $service->ID ); break;
}
$e .= apply_filters('app-services-service_description', $service_description, $service, $description) . '</div>';
}
}

So here goes...I'm running, Appointments+ Version 1.9.3 and there is nothing on lines 1199 to 1125. In fact, the coding ends at line 661. So where do I place this php code??? Still in the same file??? If, so...does it go at the end or does something need to be replaced still...please advise.

All I really need is to force the Service Dropdown menu to read "Select Service" instead of defaulting to the first Service created in the Admin backend.

Hope this helps.

Thanks guys.

  • Tyler Postle

    Hey again Arturo,

    I'm seeing 1319 lines in that file; however, that could be due to using a different code editor as some can remove spaces. I'm using Notepad++

    With that said, looks like the lines of 1199-1225 have changed since Ash's post as the ones I'm seeing definitely wouldn't make sense to replace with the code above.

    I'm going to message Ash about this one just to make sure we get that code in the right place for ya :slight_smile:

    Either myself or Ash will reply back once he's had a chance to take a closer look.

    By the way, I'd also recommend upgrading to 1.9.4.

    Talk to you soon.

    Cheers,
    Tyler

  • Ash

    Hello Arturo

    Please go to /wp-content/plugins/appointments/includes/shortcodes/class-app-shortcode-services.php line no 111 to 115 and replace:

    <select id="app_select_services" name="app_select_services" class="app_select_services">
    						<?php foreach ( $services as $service ): ?>
    							<option value="<?php echo $service->ID; ?>" <?php selected( $service->ID, $selected_service ); ?>><?php echo stripslashes( $service->name ); ?></option>
    						<?php endforeach; ?>
    					</select>

    with

    <select id="app_select_services" name="app_select_services" class="app_select_services">
                                                <?php if( ! isset( $_REQUEST['app_service_id'] ) ) : ?>
                                                <option value="">Select a Service</option>
                                                <?php endif; ?>
    						<?php foreach ( $services as $service ): ?>
    							<option value="<?php echo $service->ID; ?>" <?php selected( $service->ID, $selected_service ); ?>><?php echo stripslashes( $service->name ); ?></option>
    						<?php endforeach; ?>
    					</select>

    Please note that, this changes will be lost in next update. So it's worth to note down this changes somewhere and apply again after your updates.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.