I am trying to build a panel with multiple checkboxes to allow users to apply discounts to the total price of their cart.
To do this i am using a computed function that makes the difference between the total and the discount selected with the checkbox.
Sometimes happens that different offer have same value in the checkbox and when i click on one both of them are checked.
What i am doing wrong?
Here the javascript:
const app = new Vue({
el: '#app',
computed: {
total() {
return this.fullPrice.reduce( (sum, addon) => sum - addon, 10000);
}
},
data: {
fullPrice: [],
currency: '€',
offers: [
{
id: 'children',
text: 'Discount for children',
price: 500
},
{
id: 'senior',
text: 'Discount for senior',
price: 100
},
{
id: 'special',
text: 'Special voucher',
price: 100
},
]
}
});