Skip to content

Instantly share code, notes, and snippets.

@kartikparmar
Last active Nov 23, 2020
Embed
What would you like to do?
Updating Booking Status - Rich
<?php
function woocommerce_thankyou_change_order_status( $order_id ) {
if ( ! $order_id ) return;
$order = wc_get_order( $order_id );
if ( $order->get_status() == 'processing' ){
$order->update_status( 'pending' );
// Updating booking status.
$order_items = $order->get_items();
foreach ( $order_items as $item_key => $item_value ) {
$booking_status = wc_get_order_item_meta( $item_key, '_wapbk_booking_status' );
if ( isset( $booking_status ) && 'paid' === $booking_status ) {
$booking_status = 'confirmed';
wc_update_order_item_meta( $item_key, '_wapbk_booking_status', $booking_status );
$booking_id = bkap_common::get_booking_id( $item_key );
if ( $booking_id ) {
$new_booking = bkap_checkout::get_bkap_booking( $booking_id );
$new_booking->update_status( $booking_status );
}
}
}
}
}
add_action( 'woocommerce_thankyou', 'woocommerce_thankyou_change_order_status', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment