I've got a computed method that allows me to count a total price of my products and discount value and would like to get the value of: total - discount.
cartTotal() {
var total = 0;
var discount = Math.round((0.1 * this.cartTotal) * 100) / 100;
this.cart.items.forEach(function(item) {
total += item.quantity * item.product.price;
});
total -= discount;
return total;
}
Doens't work for me and I get that Maximum call stack size exceeded error.
this.discountValue.discountto call yourdiscountValue()method?discountValue.discountmakes no sense (neither does settingdiscountActive = truethen immediately throwing it away). What are you trying to do?discountValue()seems to assume thatcartTotal()returns a price without the discount subtracted from it, but then incartTotal()you want to subtract the discount from it. There is a logical error here. You must make up your mind: doescartTotal()include the discount or not?total.