Skip to content

Commit d27f46d

Browse files
committed
Added checkout functionality
1 parent 1b5de32 commit d27f46d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ <h1>Cart</h1>
9898

9999
<tr>
100100
<td colspan="2"></td>
101-
<td><button class="btn btn-success">Checkout</button></td>
101+
<td><button class="btn btn-success" @click="checkout">Checkout</button></td>
102102
</tr>
103103
</tbody>
104104
</table>

js/app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ new Vue({
9292
if (index !== -1) {
9393
this.cart.items.splice(index, 1);
9494
}
95+
},
96+
checkout: function() {
97+
if (confirm('Are you sure that you want to purchase these products?')) {
98+
this.cart.items.forEach(function(item) {
99+
item.product.inStock += item.quantity;
100+
});
101+
102+
this.cart.items = [];
103+
}
95104
}
96105
},
97106
computed: {

0 commit comments

Comments
 (0)