Skip to content

Instantly share code, notes, and snippets.

@LaxusCroco
Created September 20, 2023 11:52
Show Gist options
  • Save LaxusCroco/e89b30b49a2c3f3f1154bb93c5ded974 to your computer and use it in GitHub Desktop.
Save LaxusCroco/e89b30b49a2c3f3f1154bb93c5ded974 to your computer and use it in GitHub Desktop.
Replace the ID of the service in $to_skip = array( 164 ); and $to_skip = array( 13723 ); with the needed service ID.
<?php
//update appointment status
function __complete_appointment( $appointment_id ) {
if ( ! isset( $appointment_id ) ) {
return;
}
$appointment = jet_apb()->db->get_appointment_by( 'ID', $appointment_id );
if ( ! $appointment ) {
return;
}
jet_apb()->db->appointments->update(
array( 'status' => 'completed', ),
array( 'ID' => $appointment_id, )
);
jet_apb()->db->maybe_exclude_appointment_date( $appointment );
}
//disable WC-JetAppointment integration in JetEngine for specified services
add_action( 'jet-apb/form/notification/success', function( $appointments ) {
//IDs of services that should not be WC integrated
$to_skip = array( 164 );
foreach( $appointments as $item ) {
if ( in_array( $item['service'], $to_skip ) ) {
remove_action( 'jet-apb/form/notification/success', array( jet_apb()->wc, 'process_wc_notification' ), 10 );
__complete_appointment( $item['ID'] );
}
}
}, 0 );
////disable WC-JetAppointment integration in JetFormBuilder for specified services
add_action( 'jet-apb/jet-fb/action/success', function( $appointments ) {
//IDs of services that should not be WC integrated
$to_skip = array( 13723 );
foreach( $appointments as $item ) {
if ( in_array( $item['service'], $to_skip ) ) {
remove_action( 'jet-apb/jet-fb/action/success', array( jet_apb()->wc, 'process_wc_notification' ), 10 );
__complete_appointment( $item['ID'] );
}
}
}, 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment