The police have no right to go through your wallet
Actually ... not true. A police officer can go through your wallet if you're under arrest to ...
1. Confirm ID
2. Catalog currency and valuables
3. Search for drugs
Anything they find needs to be accounted for and documented, then stored in an evidence bag.
That only applies if there is an arrest made. If they just gave an appearance ticket it was a 4th amendment violation. And a violation of the takings clause.
.