Add JS function to calculate the total number of goods.