Shopping cart
Visitors to the MERN Marketplace can add products they wish to buy to a shopping cart by clicking the add to cart
button on each product. A cart icon in the menu will indicate the number of products already added to their cart as the user continues to browse through the marketplace. They can also update the cart contents and begin the checkout by opening the cart view. But to complete checkout and place an order, users will be required to sign in.
The shopping cart is mainly a frontend feature, so the cart details will be stored locally on the client side until the user places the order at checkout. To implement the shopping cart features, we will set up helper methods in client/cart/cart-helper.js
to help manipulate the cart details with relevant React components.
Adding to cart
The AddToCart
component in client/Cart/AddToCart.js
 takes a product
object and a CSS styles object as props from the parent component it is added to. For example, in MERN Marketplace, it is added to a...