I have an issue with excluding 1 product from woocommerce bookings Google calendar sync in unpaid status. I have a clients which are booking individual classes where they pay at. These classes I need to sync with my google calendar in unpaid status. 1 product is for more people and each of them have to pay before the lesson starts. I would like to sync these bookings once they are paid into my calendar.
I use this code to get unpaid bookings to my google calendar.
add_filter('woocommerce_booking_is_paid_statuses', 'woocommerce_booking_add_unpaid_to_is_paid_statuses');
function woocommerce_booking_add_unpaid_to_is_paid_statuses( $statuses ) {
$statuses[]= 'unpaid';
return $statuses;
}
I need to exclude product id 946 from this function. Could you please give me some advice how to do it? Thank you!
UPDATE
I've tried to modify function like this, but I'm still getting some error in wp.
Code
function woocommerce_bookings_kalendar( $statuses, $order ) {
// Get items in order
$items = $order->get_items();
// Loop for all items
foreach ( $items as $item ) {
$product_id = $item['product_id'];
if ( $product_id == 946 ) {
$statuses[]= 'unpaid';
return $statuses;
}
}
}
add_filter('woocommerce_booking_is_paid_statuses', 'woocommerce_bookings_kalendar');
Error:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function woocommerce_bookings_kalendar()