Created
January 30, 2017 15:18
-
-
Save machariamarigi/80ce86806fb3e644e74d63e4064f3cdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vue instance to display birtday products | |
let products = [ | |
{ | |
id: 1, | |
title: 'Awesome handy love bouquet', | |
description: 'Bundle of flowers filled with warmth to calm the heart.', | |
price: 2000, | |
image: '../assets/birthday/awesome-love-bouquet.jpg', | |
quantity: 0 | |
}, | |
{ | |
id: 2, | |
title: 'Birthday hamper', | |
description: 'Custom wrapped gift hampers.', | |
price: '', | |
image: '../assets/birthday/birthday-hamper.jpg', | |
quantity: 0 | |
}, | |
{ | |
id: 3, | |
title: 'Baby flower basket hamper', | |
description: 'Birthday gift hamper with an adorable doll.', | |
price: 4000, | |
image: '../assets/birthday/baby-flower-basket.jpg', | |
quantity: 0 | |
}, | |
{ | |
id: 4, | |
title: 'Delicious gift collection', | |
description: 'Basketful of wonderful gifts.', | |
price: 5500, | |
image: '../assets/birthday/delicious-gift-collection.jpg', | |
quantity: 0 | |
}, | |
{ | |
id: 5, | |
title: 'Doll with chocolate basket hamper', | |
description: 'Adorable goodies: a doll, lots of chocolate and flowers.', | |
price: 6000, | |
image: '../assets/birthday/doll-chocolate-gift-hamper.jpg', | |
quantity: 0 | |
}, | |
{ | |
id: 6, | |
title: 'Floral hamper', | |
description: 'A floral gift basket and gifts.', | |
price: 4500, | |
image: '../assets/birthday/floral-gift-sided.jpg', | |
quantity: 0 | |
}, | |
{ | |
id: 7, | |
title: 'Impressive blossomin flower', | |
description: 'A bouquet of lovely blossomin flowers.', | |
price: 2250, | |
image: '../assets/birthday/impressive-blossoming-flower.jpg', | |
quantity: 0 | |
}, | |
{ | |
id: 8, | |
title: 'My love birthday hamper', | |
description: 'An amazing gift for a loved one.', | |
price: 4000, | |
image: '../assets/birthday/my-love-birthday.jpg', | |
quantity: 0 | |
}, | |
{ | |
id: 9, | |
title: 'Sweet sweet pink flower', | |
description: 'Lovely pink flowers in a vase.', | |
price: 2350, | |
image: '../assets/birthday/sweet-pink.jpg', | |
quantity: 0 | |
} | |
] | |
var birthday_category = new Vue({ | |
el: '#birthday', | |
data: { | |
items: [], | |
products: products, | |
showCart: false, | |
verified: false | |
}, | |
computed: { | |
total() { | |
var total = 0; | |
for(var i = 0; i < this.items.length; i++) { | |
total += this.items[i].price; | |
} | |
return total; | |
} | |
}, | |
methods: { | |
addToCart(item) { | |
item.quantity += 1; | |
this.items.push(item); | |
}, | |
removeFromCart(item) { | |
item.quantity -= 1; | |
this.items.splice(this.items.indexOf(item), 1); | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment