Maureen Moore

Maureen Moore

  • NA
  • 206
  • 0

Grand Total Function Returns the Wrong Grand Total

Aug 13 2020 8:38 AM
This function returns the wrong grand total. When I add items to the cart, it returns a much higher grand total than is actually there. How can I fix it?
You can see the app in action at cart-64d3f.firebaseapp.com
In the component:
  1. totals = [];  
  2.   
  3. get grandTotal() {  
  4.   
  5. let i;  
  6. let sub_total = 0;  
  7. let grand_total = 0;  
  8. if (this.isSubmitted == true) {  
  9. if (typeof this.product_price !== "undefined" && typeof this.quantity !== "undefined") {  
  10. sub_total = this.product_price * this.quantity;  
  11. this.totals.push(sub_total);  
  12. }  
  13. }  
  14. for (i = 0; i < this.totals.length; i++) {  
  15. grand_total += this.totals[i];  
  16. }  
  17. return grand_total;  
  18. }  
In the HTML:
  1. <td>{{grandTotal | currency:'USD':true }}</td>  

Answers (9)