A shopping cart works by allowing users to browse and add products to their cart. The cart keeps track of the selected items, their quantities, and the total cost.