I'm using WooCommerce and Subscriptions. When customers switch the items in its subscription they go through the entire order process again and the order status is set to Processing/Completed. I wanted to change the order status to Switch order
. But my problem is I don't know what data I'm going to use to target only switch subscription orders.
add_action( 'woocommerce_thankyou', 'thankyou_change_order_status_to_switch' );
function thankyou_change_order_status_to_switch( $order_id ){
if( ! $order_id ) return;
$order = wc_get_order( $order_id );
if ( $order->has_status( 'processing' ) ) {
$order->update_status( 'switch-order' );
}
}