We found that in shops especially in Vigo & Cadiz , you needed to show proof of ID if you were paying by Credit card. They did accept my photocopy of my passport.
It depends - sometimes the ship holds your passport for the duration of the cruise, some times you get it back. It is best to keep a photocopy of the backpage on you just in case.
At most ports they just check your cruise card when you pass through the terminal and security checks for getting back on board
We are increasingly being asked for 'ID' to be taken ashore & being checked when you come back through the port's security. we do not carry our passport at the ports, they stay in the cabin safe. We take a copy of our passports, the page showing our picture only, & it is dog-eared with it being shown so many times.