This store manages the shopping cart state. It includes:
- state: Contains the cart array, where each item represents a product added to the cart.
- mutations: Methods to mutate the state. For example,
addToCart adds a product to the cart or increases the quantity if it’s already in the cart. - actions: Functions that commit mutations. The
addToCart action dispatches the mutation to add a product to the cart. - getters: Computed properties for the state. For instance,
cartItems returns all items in the cart, and cartTotal calculates the total price of the items in the cart.