Do not complete appointments automatically [Code Snippet]

Issue #920 new
Valentina R created an issue

How to not complete appointments automatically?

It doesn’t matter whether they are virtual or not, using this code snippet (or variations of it) completes the appointments:

// Remove filter for completing virtual orders.
add_action( 'init', 'bwp_remove_completing_virtual_orders' );
function bwp_remove_completing_virtual_orders() {
    // Appointments order manager class.
    $appointments_order = $GLOBALS['wc_appointment_order_manager'];

    if ( $appointments_order ) {
        // Do NOT complete appointment orders if virtual.
        remove_filter( 'woocommerce_payment_complete_order_status', array( $appointments_order, 'complete_order' ), 20 );
    }

    // Appointments cron manager class.
    $appointments_cron = $GLOBALS['WC_Appointment_Cron_Manager'];

    if ( $appointments_cron ) {
        // Do NOT complete appointment orders if virtual.
        remove_action( 'wc-appointment-complete', array( $appointments_cron, 'maybe_mark_appointment_complete' ) );
    }
}

What code snippet to use to not complete the appointments automatically.

Requested here.

Comments (0)

  1. Log in to comment