В настоящее время они устанавливаются на «неоплачиваемый».
Вот код, который я пробовал, но он не работает должным образом:
Код: Выделить всё
add_action('woocommerce_thankyou', 'set_cod_booking_status_to_confirmed', 10, 1);
function set_cod_booking_status_to_confirmed($order_id) {
$order = wc_get_order($order_id);
// Check if the payment method is Cash on Delivery
if ( $order->get_payment_method() === 'cod' ) {
// Get all bookings associated with this order
$bookings = WC_Bookings_Controller::get_bookings_for_order($order_id);
// Check if there are bookings
if (!empty($bookings)) {
// Get the first booking (if you want to confirm only the first one)
$booking = reset($bookings);
// Update the status to confirmed if it's unpaid or pending
if ($booking->get_status() === 'unpaid' || $booking->get_status() ===
'pending') {
$booking->update_status('confirmed');
}
}
}
}

Подробнее здесь: https://stackoverflow.com/questions/790 ... oocommerce