I'm currently working on creating a panel that features multiple checkboxes for users to apply discounts to their cart's total price.
To achieve this, I have implemented a computed function that calculates the difference between the total price and the discount selected via the checkbox.
However, I've noticed an issue where different offers have the same value in the checkbox, causing both of them to be checked when one is clicked.
Can anyone point out what mistake I might be making?
Below is the JavaScript code snippet being used:
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
},
]
}
});