             productType = $(addToCartBtn).data('product')
 
             if productType is "pupil"
-              worldId = $(@worldConfigActiveClass).data('id')
-              eyeId = $(@eyeConfigActiveClass).data('id')
-              id = [worldId,eyeId]
-              price = @_calcConfigSubTotal([@worldConfigActiveClass,@eyeConfigActiveClass,@licenseConfigActiveClass])
-              specs = $(@worldConfigActiveClass).data('specs') + "," + $(@eyeConfigActiveClass).data('specs')
-              license = $(@licenseConfigActiveClass).data('id')
+              worldId = $(@worldConfigActiveClass).attr('id')
+              eyeId = $(@eyeConfigActiveClass).attr('id')
+              licenseId = $(@licenseConfigActiveClass).attr('id')
+              orderItems = [worldId,eyeId,licenseId]
+              # id = [worldId,eyeId]
+              # price = @_calcConfigSubTotal([@worldConfigActiveClass,@eyeConfigActiveClass,@licenseConfigActiveClass])
+              # specs = $(@worldConfigActiveClass).data('specs') + "," + $(@eyeConfigActiveClass).data('specs')
+              # license = $(@licenseConfigActiveClass).data('id')
             else 
-              productType = $(addToCartBtn).data('product')
-              id = [$(addToCartBtn).data('id')]
-              price = $(addToCartBtn).data('cost')
-              specs = $(addToCartBtn).data('specs')
-              license = "not applicable"
+              orderItems = [$(addToCartBtn).attr('id')]
+              # id = [$(addToCartBtn).data('id')]
+              # price = $(addToCartBtn).data('cost')
+              # specs = $(addToCartBtn).data('specs')
+              # license = "not applicable"
           
-            key = @_uniqueId()
-            item = {
-              "product" : productType
-              "id": id
-              "specs": specs
-              "price": price
-              "quantity": 1
-              "license": license
-            }
-            # save to local storage & update the nav counter
-            LocalStorage.set(key, JSON.stringify(item))
+            # check if the order already exists in the cart
+            # if so, then increment the quantity of that order in the cart
+            existingOrderKey = @_compareOrders(orderItems)
+            console.log existingOrderKey
+            if existingOrderKey
+              existingOrder = JSON.parse(LocalStorage.get(existingOrderKey))
+              existingOrder.qty += 1
+              LocalStorage.set(existingOrderKey,JSON.stringify(existingOrder))
+            else
+              # add new key
+              key = @_uniqueId()
+              item = {
+                "order" : orderItems
+                "qty"   : 1
+              }
+              LocalStorage.set(key, JSON.stringify(item))
+  
+            # update the nav counter          
             @eventUpdateCartNavCounter()
           else
             return false

    id.substr 0, len
    return id


$(document).ready ->
  s = new PupilStore


  eventAddToCart: ->
    if $(@storePage).length > 0
      $(@addToCartClass).click (event)=>
          event.preventDefault()
          addToCartBtn = $(event.target)
          if not $(@addToCartBtn).hasClass('Button--state-inactive')
