Skip to content

Instantly share code, notes, and snippets.

@kartikparmar
Last active November 23, 2020 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartikparmar/7304278d21cdefe2c53700efcdf12594 to your computer and use it in GitHub Desktop.
Save kartikparmar/7304278d21cdefe2c53700efcdf12594 to your computer and use it in GitHub Desktop.
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