The carbonate ion, or #CO_3^(2-)#, has a total of 24 valence electrons, 4 from carbon, 6 from each of the three oxygen atoms, and 2 additional ones.
Three equivalent Lewis structures, also called resonance structures, can be drawn for the carbonate ion
The molecule's Lewis structure (you can pick any of the three structures shown above, since they're all equivalent) has a total of 8 lone pairs of electrons and 8 bonding electrons.
As you can see, the central carbon atom has zero lone pairs of electrons and uses all its 4 valence electrons to form bonds with three oxygen atoms: 2 single bonds and 1 double bond.
The carbon atom obeys the octet rule because it has 8 electrons in its valence shell, 2 for each bond it has with the oxygen atoms.