How to track anonymous users with Flask
There is no need for a custom AnonymousUserMixin, you can keep the shopping cart data in session:

anonymous user adds something to hist cart -> update his session with the cart data
the user wants to check out -> redirect him to login page
logged in user is back at the check out -> take his cart data out of the session and do whatever you would do if he was logged in the whole time
My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented?
The main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMixin object that is assigned to current_user. The assumption is that current_user will not change throughout the session. However, I noticed that a new AnonymousUserMixin object is assigned to current_user, for example, upon every browser page refresh. Notice that this does not happen if a user is authenticated.
Any suggestions on how to circumvent this?