How to put a variable in a instance in the widget

As far I understood you want to assign the order number like $order_number = order_generator($email) inside the widget class.

Yes, you can do it that way unless the order_generator is in another class. If you order_generator function is in another class then first you need to instantiate the class then call the method like $instance_of_your_class->order_generator($email).

Hope that helps.