title: In React/Redux, how to calculate a Total price for a shopping cart
body: <p>I've searched for solutions on Google and SO but still cannot find an answer. They all stop at "Add item to cart" or "increase/decrease quantity" but never on calculating the Total, which is annoying!</p>
  
  <p>In my app, there's a list of items where the user can enter the quantity if an item, which updates the its price. 
  All I want to know is how do you sum up all the prices of all items in a cart into a <strong>Total</strong> price, with Redux and display it in my React app? </p>
  
  <p>Also, if you can point me to any good shopping cart tutorial that actually goes beyond listing products in a cart, I'll be glad.</p>
  
  <h3>Action:</h3>
  
  <pre><code>/**
   * @description UPDATE SINGLE ITEM PRICE WHEN USER ENTER QUANTITY
   *
   * @param{number} price
   * @param{number} quantity - enter by user from input
   */
  export const updateItemPrice = (price, quantity) =&gt; dispatch =&gt; {
    const result = price * quantity;
  
    return dispatch({
      type: UPDATE_ITEM_PRICE,
      subtotal: result
    });
  };
  </code></pre>
  
  <h3>Reducer:</h3>
  
  <pre><code>const INITIAL_STATE = {
    total: 0,
    subtotal: 0
  };
  
  const productsReducer = (state = INITIAL_STATE, action) =&gt; {
    switch (action.type) {
      // Update single item price
      case Types.UPDATE_ITEM_PRICE:
        return {
          ...state,
          subtotal: action.subtotal,
          total: // --&gt; Here is where I'm stuck!!
        };
  
      default:
        return state;
    }
  };
  </code></pre>