Hello,
I have created a woocommerce booking website for my new yoga studio.
When clients choose to make a new booking by paying “Cash on Delivery” the booking status is automatically set to unpaid.
However, I would like to automatically set it to “confirmed”.
I have tried to add custom code to my functions.php file but they don’t work.
add_action( 'woocommerce_new_booking', 'auto_confirm_cod_bookings', 10, 1 );function auto_confirm_cod_bookings( $booking_id ) {
$booking = new WC_Booking( $booking_id );
$order = $booking->get_order();
if ( $order && $order->get_payment_method() === 'cod' ) {
// Change status to confirmed
$booking->update_status( 'confirmed' );
}
}