Browse Source

[ADD] calculate subtotal in cart items

Gogs 7 years ago
parent
commit
b883179aa4
2 changed files with 4 additions and 4 deletions
  1. 1 0
      src/App.vue
  2. 3 4
      src/components/CartItem.vue

+ 1 - 0
src/App.vue

@@ -33,6 +33,7 @@
             width: calc(100% - 300px)
             height: 100%
             padding-right: 5px
+
              
         .cart-container
             width: 300px

+ 3 - 4
src/components/CartItem.vue

@@ -1,11 +1,11 @@
 <template lang="pug">
         .cart-item
             h3.item-name {{ item.name }}
-            input.item-quantity(type="text")
+            input.item-quantity(type="text" :value="item.qty")
             span.item-x x
             span.item-price Gs {{ item.list_price }}
             span.item-equals =
-            span.item-subtotal Gs {{ item.list_price }}
+            span.item-subtotal Gs {{ item.list_price * item.qty }}
 </template>
 
 <script>
@@ -20,8 +20,7 @@
             }
         },
         mounted() {
-            console.log(this)
-            console.log(_)
+            this.$set(this.item, 'qty', 1)
         }
     }
 </script>