get_col( $wpdb->prepare( "SELECT posts.ID FROM {$wpdb->posts} AS posts WHERE posts.post_type IN ({$escaped_post_types}) AND posts.post_status = '%s' AND posts.post_modified < %s", $pending_status, $date->format( 'Y-m-d H:i:s' ) ) ); // @codingStandardsIgnoreEnd /* The code fragment below is copied from wc_cancel_unpaid_orders function. */ if ( $unpaid_orders ) { foreach ( $unpaid_orders as $unpaid_order ) { $order = wc_get_order( $unpaid_order ); if ( apply_filters( 'woocommerce_cancel_unpaid_order', 'checkout' === $order->get_created_via(), $order ) ) { $order->update_status( 'cancelled', __( 'Unpaid order cancelled - time limit reached.', 'woocommerce' ) ); } } } } }