Below, you’ll find a detailed guide on how to add the Simply Schedule Appointments Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Simply Schedule Appointments Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Simply Schedule Appointments Plugin and the shortcodes it provides:
"Appointment Booking Calendar – Simply Schedule Appointments Booking Plugin is a user-friendly tool for managing and scheduling your appointments seamlessly. Ideal for businesses seeking efficiency."
- [ssa_booking]
- [tec_ssa_booking]
- [ssa_past_appointments]
- [ssa_upcoming_appointments]
- [ssa_admin_upcoming_appointments]
- [ssa_admin]
- [ssa_confirmation]
Simply Schedule Appointments [ssa_booking] Shortcode
The Simply Schedule Appointments shortcode is a tool that integrates a booking system into your WordPress site. It validates types and labels of appointments, handles payments, and manages appointment confirmation. It also provides error messages for invalid attributes and unsupported browsers.
Shortcode: [ssa_booking]
Parameters
Here is a list of all possible ssa_booking shortcode parameters and attributes:
types
– specifies the available appointment types.label
– filters appointments based on label.type
– determines a specific appointment type to display.integration
– allows integration with other plugins or forms.edit
– enables editing of a pre-existing appointment.view
– sets the view mode for the booking interface.
Examples and Usage
Basic example – Display a booking form with a specific appointment type.
[ssa_booking type="consultation" /]
Advanced examples
Display a booking form with a specific appointment type and a specific label. If the type is not found, it will try to load the appointment types associated with the label.
[ssa_booking type="consultation" label="premium" /]
Display a booking form with a specific appointment type and enable the edit option. This allows the user to edit their appointment details.
[ssa_booking type="consultation" edit="1" /]
Display a booking form with a specific appointment type and a specific integration. This enables the form to be integrated with other services like a payment gateway or a CRM system.
[ssa_booking type="consultation" integration="stripe" /]
Display a booking form with a specific appointment type and a specific view. This allows you to control the display of the booking form.
[ssa_booking type="consultation" view="calendar" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [ssa_booking]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ssa_booking', array( $this, 'ssa_booking' ) );
Shortcode PHP function:
function ssa_booking( $atts, $is_embedded_page = false ) {
$atts = shortcode_atts( $this->get_ssa_booking_arg_defaults(), $atts, 'ssa_booking' );
$atts = apply_filters( 'ssa_booking_shortcode_atts', $atts );
$paypal_payment = isset($_GET['paypal_payment']) ? esc_attr($_GET['paypal_payment']): '';
$stripe_payment = isset($_GET['stripe_payment']) ? esc_attr($_GET['stripe_payment']): '';
if(isset($_GET["paypal_cancel"]) && "1" === $_GET["paypal_cancel"]){
$_GET["paypal_cancel"] = true;
return $this->ssa_confirmation();
}
if($paypal_payment){
$_GET["paypal_payment"] = 0;
return $this->ssa_confirmation();
}
if( $stripe_payment ){
$_GET['stripe_payment'] = 0;
return $this->ssa_confirmation();
}
// First validate atts['types'] if set
if( ! empty( $atts['types'] ) ){
$types = sanitize_text_field( esc_attr( $atts['types'] ) );
$is_valid = $this->is_valid_types_attribute( $types );
if( ! $is_valid ){
$error_message = '<h3>' . __('Sorry, no appointment types available, please check back later.', 'simply-schedule-appointments') . '</h3>';
if ( current_user_can( 'ssa_manage_site_settings' ) ) {
$error_message .= '<code>' . sprintf( __('The specified appointment types \'%1$s\' can\'t be found %2$s (this message is only viewable to site administrators)', 'simply-schedule-appointments'),
$types,
'</code>' );
}
return $error_message;
}
}
// Check for atts['label'] if set, and convert it to atts['types']
if( ! empty( $atts['label'] ) ) {
$label = sanitize_text_field( esc_attr( $atts['label'] ) );
$ids = $this->convert_label_to_appt_types_ids( $label );
if ( empty( $ids ) ) {
$error_message = '<h3>' . __('Sorry, no appointment types available for this label, please check back later.', 'simply-schedule-appointments') . '</h3>';
if ( current_user_can( 'ssa_manage_site_settings' ) ) {
$error_message .= '<code>' . sprintf( __('The specified appointment type label \'%1$s\' can\'t be found, or has no appointment types available %2$s (this message only viewable to site administrators)', 'simply-schedule-appointments'),
$label,
'</code>' );
}
return $error_message;
} else {
$atts['types'] = $ids;
}
}
$appointment_type = '';
if ( ! empty( $atts['type'] ) ) {
if ( $atts['type'] == (string) (int) $atts['type'] ) {
// integer ID provided
$appointment_type_id = (int) sanitize_text_field( $atts['type'] );
} else {
// slug provided
$appointment_types = $this->plugin->appointment_type_model->query(
array(
'slug' => sanitize_text_field( $atts['type'] ),
'status' => 'publish',
)
);
if ( ! empty( $appointment_types['0']['id'] ) ) {
$appointment_type_id = $appointment_types['0']['id'];
}
if ( empty( $appointment_type_id ) ) {
$type = sanitize_text_field( esc_attr( $atts['type'] ) );
$error_message = '<h3>' . __('Sorry this appointment type isn\'t available, please check back later', 'simply-schedule-appointments') . '</h3>';
if ( current_user_can( 'ssa_manage_site_settings' ) ) {
$error_message .= '<code>' . sprintf( __('The specified appointment type \'%1$s\' can\'t be found %2$s (this message only viewable to site administrators)', 'simply-schedule-appointments'),
$type,
'</code>' );
}
return $error_message;
}
}
if ( ! empty( $appointment_type_id ) ) {
$appointment_type = $this->plugin->appointment_type_model->get( $appointment_type_id );
if ( empty( $atts['types'] ) ) {
$atts['types'] = $appointment_type_id;
}
}
}
if ( $is_embedded_page || $this->is_embedded_page() ) {
// wp_localize_script( 'ssa-booking-app', 'ssaBookingParams', array(
// 'apptType' => $appointment_type,
// 'translatedStrings' => array(
// ),
// ) );
wp_localize_script( 'ssa-booking-app', 'ssa', $this->plugin->bootstrap->get_api_vars() );
wp_localize_script( 'ssa-booking-app', 'ssa_translations', $this->get_translations() );
wp_enqueue_script( 'ssa-unsupported-script' );
wp_enqueue_script( 'ssa-booking-manifest' );
wp_enqueue_script( 'ssa-booking-vendor' );
wp_enqueue_script( 'ssa-booking-app' );
wp_enqueue_script( 'ssa-iframe-inner' );
return '
<div id="ssa-booking-app">
<noscript>
<div class="unsupported">
<div class="unsupported-container">
<h1 class="unsupported-label">' . __( 'Simply Schedule Appointments requires JavaScript', 'simply-schedule-appointments' ) . '</h1>
<p class="unsupported-description">' . __( 'To book an appointment, please make sure you enable JavaScript in your browser.', 'simply-schedule-appointments' ) . '</p>
</div>
</div>
</noscript>
</div>
<div id="ssa-unsupported" style="display:none;">
<div class="unsupported">
<div class="unsupported-container">
<h1 class="unsupported-label">' . __( 'Unsupported Browser', 'simply-schedule-appointments' ) . '</h1>
<p class="unsupported-description">' . __( 'To book an appointment, please update your browser to something more modern. We recommend Firefox or Chrome.', 'simply-schedule-appointments' ) . '</p>
</div>
</div>
</div>
';
}
wp_localize_script( 'ssa-iframe-outer', 'ssa', $this->plugin->bootstrap->get_api_vars() );
wp_enqueue_script( 'ssa-iframe-outer' );
if ( $this->plugin->settings_installed->is_enabled( 'tracking' ) ) {
wp_enqueue_script( 'ssa-tracking' );
}
if ( ! empty( $atts['integration'] ) ) {
wp_enqueue_script( 'ssa-form-embed' );
}
$settings = $this->plugin->settings->get();
// $link = get_page_link( $settings['global']['booking_post_id'] );
$api_vars = $this->plugin->bootstrap->get_api_vars();
if ( ! empty( $atts['edit'] ) ) {
$appointment_id = sanitize_text_field( $atts['edit'] );
if ( ! empty( $appointment_id ) ) {
$appointment = SSA_Appointment_Object::instance( $appointment_id );
$appointment_type_id = $appointment->get_appointment_type()->id;
if ( empty( $atts['types'] ) ) {
$atts['types'] = $appointment_type_id;
}
}
}
$link = add_query_arg( $atts, $api_vars['api']['root'] . '/embed-inner' );
if ( ! empty( $atts['edit'] ) ) {
$appointment_id = sanitize_text_field( $atts['edit'] );
// if it's an integration form, and the appointment status is 'pending_form', load the appointment on a pre confirmed state.
if ( ! empty( $atts['integration'] ) && $appointment->is_reserved() ) {
$appointment_id_token = ! empty( $atts['token'] ) ? $atts['token'] : $this->plugin->appointment_model->get_id_token( array( 'id' => sanitize_text_field( $atts['edit'] ) ) );
$link = add_query_arg( array( 'token' => $appointment_id_token ), $link );
$link = $link . '#/load-appointment/' . $appointment_id;
} else {
$appointment_id_token = $this->plugin->appointment_model->get_id_token( array( 'id' => $appointment_id ) );
$link = $link . '#/change/' . $appointment_id_token . $appointment_id;
}
} else {
$link = $link . '#/';
}
if ( ! empty( $atts['integration'] ) ) {
$link = str_replace( '#/', '#/integration/' . esc_attr( $atts['integration'] ) . '/', $link );
}
if ( ! empty( $atts['view'] ) ) {
$link .= '/view/' . $atts['view'];
}
$link = SSA_Bootstrap::maybe_fix_protocol( $link );
$escaped_passed_args = array();
foreach ( $this->get_passed_args() as $passed_key => $passed_value ) {
if ( ! is_string( $passed_key ) || ! is_string( $passed_value ) ) {
continue; // needed to prevent error rendering gutenberg block
}
// at this point any escaped passed value has been decoded
// the encode step below will handle the affected characters
$passed_value = urlencode( $passed_value );
if ( $passed_key === 'Email' ) {
$passed_value = str_replace( '+', '%2B', trim( $passed_value ) ); // since + is a URL equivalent of %20, an email like 'example+123@gmail.com' needs to be re-encoded to prevent it from becoming 'example 123@gmail.com'
}
// if the first char of phone is a +, meaning the URL contained a literal unescaped +, it should be encoded to %2B
if ( $passed_key === 'Phone' ) {
$passed_value = preg_replace( '/^(\+)(.*)/', '%2B$2', $passed_value );
}
$escaped_passed_args[ htmlspecialchars( $passed_key ) ] = htmlspecialchars( $passed_value );
}
$link = add_query_arg( $escaped_passed_args, $link );
$lazy_load_mode = apply_filters( 'ssa/performance/lazy_load', false );
if ( false === $lazy_load_mode ) {
$iframe_src = '<iframe src="' . $link . '" height="400px" width="100%" name="ssa_booking" loading="eager" frameborder="0" data-skip-lazy="1" class="ssa_booking_iframe skip-lazy" title="' . esc_attr__( 'Book a time', 'simply-schedule-appointments' ) . '"></iframe>';
} elseif ( true === $lazy_load_mode ) {
$iframe_src = '<iframe src="' . $link . '" height="400px" width="100%" name="ssa_booking" loading="lazy" frameborder="0" class="ssa_booking_iframe" title="' . esc_attr__( 'Book a time', 'simply-schedule-appointments' ) . '"></iframe>';
} else {
$iframe_src = '<iframe src="' . $link . '" height="400px" width="100%" name="ssa_booking" frameborder="0" class="ssa_booking_iframe" title="' . esc_attr__( 'Book a time', 'simply-schedule-appointments' ) . '"></iframe>';
}
return $iframe_src;
}
Code file location:
simply-schedule-appointments/simply-schedule-appointments/includes/class-shortcodes.php
Simply Schedule Appointments [tec_ssa_booking] Shortcode
The Simply Schedule Appointments shortcode is a powerful tool that integrates event scheduling within your WordPress site. This shortcode checks if the current post is an event and, if so, fetches the event’s start and end dates. It then merges these dates into the shortcode’s attributes, allowing for the scheduling of appointments within the event’s duration.
Shortcode: [tec_ssa_booking]
Parameters
Here is a list of all possible tec_ssa_booking shortcode parameters and attributes:
availability_start_date
– sets the start date for appointment availabilityavailability_end_date
– sets the end date for appointment availability
Examples and Usage
Basic example – This shortcode enables the scheduling of appointments within a specific event timeframe. It uses the event’s start and end dates as the availability window.
[tec_ssa_booking]
Advanced examples
Customizing the availability window for appointment booking. This shortcode uses explicit start and end dates, overriding the default event dates.
[tec_ssa_booking availability_start_date="2022-01-01 00:00:00" availability_end_date="2022-12-31 23:59:59"]
Another advanced usage could be to set a specific start date but leave the end date to default to the event’s end date.
[tec_ssa_booking availability_start_date="2022-01-01 00:00:00"]
Alternatively, you could set a specific end date and leave the start date to default to the event’s start date.
[tec_ssa_booking availability_end_date="2022-12-31 23:59:59"]
These examples provide flexibility for users in scheduling appointments, making the ‘simply-schedule-appointments’ plugin a versatile tool for managing bookings within WordPress.
PHP Function Code
In case you have difficulties debugging what causing issues with [tec_ssa_booking]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'tec_ssa_booking', array( $this, 'tec_ssa_booking' ) );
Shortcode PHP function:
function tec_ssa_booking( $atts = array() ) {
$post_id = get_the_ID();
if ( ! function_exists( 'tribe_is_event' ) || ! tribe_is_event( $post_id ) ) {
return $this->ssa_booking( $atts );
}
$event = tribe_get_event( $post_id );
if ( empty( $atts ) ) {
$atts = array();
}
$atts = array_merge(
array(
'availability_start_date' => $event->dates->start_utc->format( 'Y-m-d H:i:s' ),
'availability_end_date' => $event->dates->end_utc->format( 'Y-m-d H:i:s' ),
),
$atts
);
return $this->ssa_booking( $atts );
}
Code file location:
simply-schedule-appointments/simply-schedule-appointments/includes/class-shortcodes.php
Simply Schedule Appointments [ssa_past_appointments] Shortcode
The Simply Schedule Appointments shortcode is a specialized code that displays a user’s past appointments. It retrieves bookings based on predefined parameters like status, number, order, and customer ID. It also allows customization of messages displayed when no results are found or when the user is logged out. Additionally, it provides options to display a link for appointment details and a web meeting URL.
Shortcode: [ssa_past_appointments]
Parameters
Here is a list of all possible ssa_past_appointments shortcode parameters and attributes:
status
– Specifies the booking status of the appointmentsnumber
– Defines the maximum number of appointments to displayorderby
– Determines the field by which appointments are sortedorder
– Defines the sorting order, either ascending or descendingcustomer_id
– Identifies the customer by their user IDno_results_message
– Sets the message displayed when there are no past appointmentslogged_out_message
– Specifies the message shown when the user is logged outend_date_max
– Sets the maximum end date and time for appointmentsdetails_link_displayed
– Determines whether the details link is displayeddetails_link_label
– Sets the label for the details linkweb_meeting_url
– Sets the URL for the web meeting, if anyappointment_type_displayed
– Specifies whether the appointment type is displayed
Examples and Usage
Basic example – Display the past appointments of the current logged-in user. The shortcode will return the last 10 appointments that have been booked, ordered by the start date in descending order.
[ssa_past_appointments /]
Advanced examples
Display the past appointments of a specific user. This shortcode will return the last 10 appointments that have been booked by the user with the ID 5, ordered by the start date in descending order.
[ssa_past_appointments customer_id=5 /]
Change the number of past appointments displayed and the order. This shortcode will return the last 5 appointments that have been booked by the current logged-in user, ordered by the start date in ascending order.
[ssa_past_appointments number=5 order=ASC /]
Display the past appointments with a custom no results message. If there are no past appointments, the shortcode will display the message “You have no past appointments”.
[ssa_past_appointments no_results_message="You have no past appointments" /]
Display the past appointments along with the appointment type. This shortcode will return the last 10 appointments that have been booked by the current logged-in user, along with the type of appointment.
[ssa_past_appointments appointment_type_displayed=true /]
PHP Function Code
In case you have difficulties debugging what causing issues with [ssa_past_appointments]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ssa_past_appointments', array( $this, 'ssa_past_appointments' ) );
Shortcode PHP function:
function ssa_past_appointments( $atts ) {
$atts = shortcode_atts(
array(
'status' => 'booked',
'number' => 10,
'orderby' => 'start_date',
'order' => 'DESC',
'customer_id' => get_current_user_id(),
'no_results_message' => __( 'No past appointments', 'simply-schedule-appointments' ),
'logged_out_message' => '',
'end_date_max' => ssa_datetime()->format( 'Y-m-d H:i:s' ),
'details_link_displayed' => true,
'details_link_label' => __( 'View Details', 'simply-schedule-appointments' ),
'web_meeting_url' => false,
'appointment_type_displayed' => false,
),
$atts,
'ssa_upcoming_appointments'
);
ob_start();
include $this->plugin->dir( 'templates/customer/past-appointments.php' );
$output = ob_get_clean();
return $output;
}
Code file location:
simply-schedule-appointments/simply-schedule-appointments/includes/class-shortcodes.php
Simply Schedule Appointments [ssa_upcoming_appointments] Shortcode
The Simply Schedule Appointments shortcode, ‘ssa_upcoming_appointments’, displays a list of upcoming appointments. It sorts them in ascending order by start date and provides a ‘View Details’ link. This shortcode allows customization of the displayed information. It can show a message when no appointments are booked, a link to the web meeting, and the appointment type.
Shortcode: [ssa_upcoming_appointments]
Parameters
Here is a list of all possible ssa_upcoming_appointments shortcode parameters and attributes:
status
– identifies the status of the appointment, default is ‘booked’number
– indicates the number of appointments to display, -1 shows allorderby
– sets the order of the appointments, default is by ‘start_date’order
– sets the order direction, default is ‘ASC’ or ascendingcustomer_id
– identifies the customer by their user IDno_results_message
– message displayed when no appointments are foundlogged_out_message
– message shown to logged out usersstart_date_min
– sets the minimum start date for appointmentsdetails_link_displayed
– shows or hides the ‘View Details’ link, default is truedetails_link_label
– sets the label for the ‘View Details’ linkweb_meeting_url
– shows or hides the meeting URL, default is trueappointment_type_displayed
– shows or hides the appointment type, default is false
Examples and Usage
Basic Example – The following shortcode displays all booked appointments for the current user, ordered by start date in ascending order.
[ssa_upcoming_appointments]
Advanced Examples
Display only the first 5 upcoming appointments for the current user, ordered by start date in ascending order:
[ssa_upcoming_appointments number=5]
Show the upcoming appointments for a specified customer (replace ‘123’ with the actual customer ID), ordered by start date in ascending order:
[ssa_upcoming_appointments customer_id=123]
Display upcoming appointments for the current user, ordered by start date in descending order:
[ssa_upcoming_appointments order='DESC']
Show upcoming appointments for the current user, with a custom ‘No upcoming appointments’ message:
[ssa_upcoming_appointments no_results_message='You have no upcoming appointments']
Display the upcoming appointments for the current user, with the appointment type displayed:
[ssa_upcoming_appointments appointment_type_displayed=true]
PHP Function Code
In case you have difficulties debugging what causing issues with [ssa_upcoming_appointments]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ssa_upcoming_appointments', array( $this, 'ssa_upcoming_appointments' ) );
Shortcode PHP function:
function ssa_upcoming_appointments( $atts ) {
$atts = shortcode_atts(
array(
'status' => 'booked',
'number' => -1,
'orderby' => 'start_date',
'order' => 'ASC',
'customer_id' => get_current_user_id(),
'no_results_message' => __( 'No upcoming appointments', 'simply-schedule-appointments' ),
'logged_out_message' => '',
'start_date_min' => ssa_datetime()->sub( new DateInterval( 'PT1H' ) )->format( 'Y-m-d H:i:s' ),
'details_link_displayed' => true,
'details_link_label' => __( 'View Details', 'simply-schedule-appointments' ),
'web_meeting_url' => true,
'appointment_type_displayed' => false,
),
$atts,
'ssa_upcoming_appointments'
);
ob_start();
include $this->plugin->dir( 'templates/customer/upcoming-appointments.php' );
$output = ob_get_clean();
return $output;
}
Code file location:
simply-schedule-appointments/simply-schedule-appointments/includes/class-shortcodes.php
Simply Schedule Appointments [ssa_admin_upcoming_appointments] Shortcode
The Simply Schedule Appointments shortcode is a powerful tool that displays upcoming appointments for admins. This shortcode fetches data based on specific parameters like status, number, order, and more. It can show appointments booked by a specific customer, or for particular staff members. It also allows customization of no-results and logged-out messages, and the display of details link, web meeting URL, appointment type, and team members.
Shortcode: [ssa_admin_upcoming_appointments]
Parameters
Here is a list of all possible ssa_admin_upcoming_appointments shortcode parameters and attributes:
status
– defines the status of the appointment, default is ‘booked’number
– indicates the number of appointments, default is 5orderby
– determines the order of appointments, default is ‘start_date’order
– sets the sorting order of appointments, default is ‘ASC’customer_id
– specifies the ID of the customerstaff_ids_any
– allows to filter appointments by staff IDno_results_message
– sets the message when no appointments are foundlogged_out_message
– sets the message when the user is logged outstart_date_min
– sets the minimum start date for the appointmentsdetails_link_displayed
– controls if the ‘View Details’ link is displayeddetails_link_label
– sets the label for the ‘View Details’ linkweb_meeting_url
– controls if the URL for the web meeting is displayedappointment_type_displayed
– controls if the appointment type is displayedteam_members_displayed
– controls if the team members are displayed
Examples and Usage
Basic example – Display the upcoming appointments with the default parameters.
[ssa_admin_upcoming_appointments]
Advanced examples
Display the upcoming appointments for a specific customer, ordered by the start date in descending order, and showing a maximum of 10 appointments.
[ssa_admin_upcoming_appointments customer_id="123" orderby="start_date" order="DESC" number="10"]
Display the upcoming appointments for a specific team member, showing a maximum of 5 appointments, with the appointment type displayed, and a custom message when there are no upcoming appointments.
[ssa_admin_upcoming_appointments staff_ids_any="456" number="5" appointment_type_displayed="true" no_results_message="No appointments scheduled for this team member."]
Display the upcoming appointments, showing the web meeting URL, and not displaying the team members.
[ssa_admin_upcoming_appointments web_meeting_url="true" team_members_displayed="false"]
PHP Function Code
In case you have difficulties debugging what causing issues with [ssa_admin_upcoming_appointments]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ssa_admin_upcoming_appointments', array( $this, 'ssa_admin_upcoming_appointments' ) );
Shortcode PHP function:
function ssa_admin_upcoming_appointments( $atts ) {
$atts = shortcode_atts(
array(
'status' => 'booked',
'number' => 5,
'orderby' => 'start_date',
'order' => 'ASC',
'customer_id' => '',
'staff_ids_any' => current_user_can( 'ssa_manage_others_appointments' ) ? []: [ $this->plugin->staff_model->get_staff_id_for_user_id( get_current_user_id() ) ],
'no_results_message' => __( 'No upcoming appointments', 'simply-schedule-appointments' ),
'logged_out_message' => '',
'start_date_min' => ssa_datetime()->sub( new DateInterval( 'PT1H' ) )->format( 'Y-m-d H:i:s' ),
'details_link_displayed' => true,
'details_link_label' => __( 'View Details', 'simply-schedule-appointments' ),
'web_meeting_url' => true,
'appointment_type_displayed' => false,
'team_members_displayed' => true,
),
$atts,
'ssa_admin_upcoming_appointments'
);
ob_start();
include $this->plugin->dir( 'templates/dashboard/dashboard-upcoming-appointments-widget.php' );
$output = ob_get_clean();
return $output;
}
Code file location:
simply-schedule-appointments/simply-schedule-appointments/includes/class-shortcodes.php
Simply Schedule Appointments [ssa_admin] Shortcode
The Simply Schedule Appointments shortcode is a tool that manages user access to appointment settings. It verifies if the user is logged in and has the appropriate permissions. If not, it displays a warning message. It also creates a nonce for the admin page and enqueues a script. The shortcode adds a query arg to the API root, and if a ‘ssa_state’ URL parameter exists, it adds it to the iframe src. The result is an iframe that displays the admin page for managing appointments.
Shortcode: [ssa_admin]
Examples and Usage
Basic example – Display the appointment booking interface for logged-in users with the appropriate permissions.
[ssa_admin /]
PHP Function Code
In case you have difficulties debugging what causing issues with [ssa_admin]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ssa_admin', array( $this, 'ssa_admin' ) );
Shortcode PHP function:
function ssa_admin() {
if( ! is_user_logged_in() ) {
return;
}
// If current user or visitor can't manage appointments, display a warning message.
if ( ! current_user_can( 'ssa_manage_appointments' ) ) {
return '<div class="ssa-admin-warning">' . __( 'It looks like you\'re not allowed to see this screen. Please check with your site administrator if you think this message is an error.', 'simply-schedule-appointments' ) . '</div>';
}
// Make sure we have the nonce for the admin page.
$nonce = wp_create_nonce( 'wp_rest' );
wp_localize_script( 'ssa-iframe-outer', 'ssa', $this->plugin->bootstrap->get_api_vars() );
wp_enqueue_script( 'ssa-iframe-outer' );
$api_vars = $this->plugin->bootstrap->get_api_vars();
$link = add_query_arg(
array(
'_wpnonce' => $nonce,
),
$api_vars['api']['root'] . '/embed-inner-admin'
);
// Check if we have a 'ssa_state' url parameter on the current page. If so, we need to add it to the iframe src as a url hash.
$ssa_state = isset( $_GET['ssa_state'] ) ? sanitize_text_field( $_GET['ssa_state'] ) : '';
if ( ! empty( $ssa_state ) ) {
$link = $link . '#' . $ssa_state;
}
$link = SSA_Bootstrap::maybe_fix_protocol( $link );
return '<iframe src="' . $link . '" height="400px" width="100%" name="ssa_admin" loading="eager" frameborder="0" data-skip-lazy="1" class="ssa_booking_iframe skip-lazy"></iframe>';
}
Code file location:
simply-schedule-appointments/simply-schedule-appointments/includes/class-shortcodes.php
Simply Schedule Appointments [ssa_confirmation] Shortcode
The Simply Schedule Appointments shortcode, ‘ssa_confirmation’, is used to confirm booking appointments. This shortcode validates the appointment token and ID. If they are incorrect, an error message is displayed. It also handles different payment statuses from PayPal and Stripe. If a payment is canceled, it shows a ‘canceled_payment’ view. If a payment is successful or failed, it shows a ‘confirm_payment’ view.
Shortcode: [ssa_confirmation]
Examples and Usage
Basic example – Displays the booking confirmation using the shortcode. In this case, the shortcode does not require any parameters.
[ssa_confirmation /]
PHP Function Code
In case you have difficulties debugging what causing issues with [ssa_confirmation]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'ssa_confirmation', array( $this, 'ssa_confirmation' ) );
Shortcode PHP function:
function ssa_confirmation() {
$appointment_token = isset($_GET['appointment_token']) ? esc_attr($_GET['appointment_token']): (isset($_POST["appointment_token"]) ? esc_attr( $_POST["appointment_token"]): '');
$error_message = '';
$paypal_success = isset($_GET['paypal_success']) ? esc_attr($_GET['paypal_success']): '';
$paypal_cancel = isset($_GET['paypal_cancel']) ? esc_attr($_GET['paypal_cancel']): '';
if(empty($appointment_token)) {
if ( current_user_can( 'ssa_manage_site_settings' ) ) {
$error_message = '<h3 style="text-align: center">'. __('Simply Schedule Appointments Booking Confirmation' , 'simply-schedule-appointments') . '</h3>';
}
return $error_message;
}
// Validate Token and Appointment ID
$provided_hash = substr($appointment_token, 0, 32);
$appointment_id = substr($appointment_token, 32);
$correct_hash = $this->plugin->appointment_model->get_id_token( array( 'id' => $appointment_id ) );
if ( $correct_hash != $provided_hash ) {
$error_message = '<h3 style="text-align: center">'. __('An error occurred, please check the URL.' , 'simply-schedule-appointments' ) . '</h3>';
return $error_message;
}
$atts = array( 'edit' => $appointment_id );
if ( "1" === $paypal_cancel ) {
$atts = array_merge(array( 'view' => 'canceled_payment', 'payment_provider' => 'paypal' ), $atts);
} else if ( ! empty( $paypal_success ) || ! empty( $paypal_cancel ) ) {
// continue to show ssa_booking - consider appointment abandoned
$atts = array_merge(array( 'view' => "confirm_payment", 'payment_provider' => 'paypal' ), $atts);
}
if( isset( $_GET['stripe_payment'] ) && $_GET['stripe_payment'] === 0 ){
if( isset( $_GET['redirect_status'] ) && $_GET['redirect_status'] === "failed" ){
$atts = array_merge(array( 'view' => "canceled_payment", 'payment_provider' => 'stripe' ), $atts);
} else {
// Here we assume $_GET['redirect_status'] is "success"
// We show the user confirm_payment view
// The frontend will take over and only show the confirmation if the appointment status was updated to be booked
$atts = array_merge(array( 'view' => "confirm_payment", 'payment_provider' => 'stripe' ), $atts);
}
}
return $this->ssa_booking( $atts );
}
Code file location:
simply-schedule-appointments/simply-schedule-appointments/includes/class-shortcodes.php
Conclusion
Now that you’ve learned how to embed the Simply Schedule Appointments Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply