How to run a command if a player is sitting in a tagged minecart?

Solution 1:

The NBT of a vehicle that you sit in is included in the "RootVehicle" tag of your player NBT. And since the NBT tag "Tags" is synchronised with the entity's tag list (from /tag), it's reachable that way.

So you can for example select yourself if you sit in a minecart tagged with "a" like this:

@s[nbt={RootVehicle:{Entity:{id:"minecraft:minecart",Tags:["a"]}}}]