Cancel appointments in front end...

Hi

I'm setting up a simple booking system using Appointments+ plugin which will allow users to create and cancel bookings all from one page in the front end of the site... everything is working fine except I want the user to be able to cancel appointments by adding a cancel tickbox to the All Appointments list/shortcode, just like the option that is available in the My Appointments list/shortcode.

The two lists/shortcodes look so similar that I can't believe it's too difficult to add the cancel feature to the All Appointments list?

Hope you can help.

Matt

  • Kasia Swiderska

    Hi Matt,

    Yes, indeed there is no "cancel" attribute for [app_all_appointments]. [app_my_appointments] shows appointments for logged in user - and it is natural that he can cancel it, and [app_all_appointments] shows appointments that are visible for everyone - I'm thinking that it wouldn't be great if some one cancel not his appointment.
    But I will check with plugin dev if there is a way to change that shortcode.

    Kind regards,
    Kasia

    • Kasia Swiderska

      Hi @Matt,

      I've talk with the developer and he provided code for [app_all_appointments] that adds cancel link. This will work bit different than in my appointments, but allows to cancel from all appointments list.
      To use that code, you have to be sure that you set "Appointment cancelled page" in Appointments settings (General tab).
      You can insert this code to your theme functions.php file

      function my_app_extend_all_header ($head) {
      	$head .= '<th>' . esc_html(__('Cancel')) . '</th>';
      	return $head;
      }
      add_filter('app_all_appointments_column_name', 'my_app_extend_all_header');
      
      function my_app_add_cancel_cell ($markup, $app) {
      	if (!is_object($app) || empty($app->ID)) return $markup;
      	if (empty($app->status) || !in_array($app->status, array('pending', 'confirmed', 'paid'))) return $markup;
      
      	global $appointments;
      
      	$extra = '' .
      		'<td>' .
      			'<a href="' . esc_url($appointments->add_cancel_link('CANCEL', $app->ID)) . '">' .
      				esc_html(__('Cancel')) .
      			'</a>' .
      		'</td>' .
      	'';
      	return $markup . $extra;
      }
      add_filter('app-shortcode-all_appointments-after_status', 'my_app_add_cancel_cell', 10, 2);

      Please, give it a try and let me know how this works for you.

      Kind regards,
      Kasia

  • Kasia Swiderska

    Hi Matt,

    Sorry for the delay here! I understand that it looks similar and easy to change, but in fact my_appointments shortcode is quite complex and moving part of it to all_appointments require more than simple pasting code (but this was mentioned before as feature request, so hopefully it will be supported by more members of our community).
    However I would suggest other solution for that:
    Activate "Administrative Permissions" add-on from the following path.
    Admin Area -> Appointments -> Settings -> Add-ons
    Then configure the permissions to access various Appointments + settings from the following path.
    Admin Area -> Appointments -> Settings -> General -> Appointments role access

    This way you can give users from the team access to appointments list in WordPress Dashboard, where they could cancel the appointments.

    Kind regards,
    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.