From c094408ac28e20d6b684e924f449ca312d84b48c Mon Sep 17 00:00:00 2001 From: Daniel Camargo Date: Fri, 18 Jan 2013 13:56:47 -0200 Subject: [PATCH] fixed #656 The problem was fixed. The tip value was being changed but it was not recalculating the total with the new tip value. --- www/assets/js/app.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/www/assets/js/app.js b/www/assets/js/app.js index 34b4144eb..bac512c3c 100644 --- a/www/assets/js/app.js +++ b/www/assets/js/app.js @@ -852,17 +852,24 @@ App.cart = { * the default tip will be 15% (variable App.order.tip). * If the user had changed the tip value the default value will be chosed one. */ + var wasTipChanged = false; if( App.order.delivery_type == 'takeout' && App.order['pay_type'] == 'card' ){ if( typeof App.order.tipHasChanged == 'undefined' ){ - $('[name="pay-tip"]').val( 0 ); App.order.tip = 0; + wasTipChanged = true; } } else if( App.order.delivery_type == 'delivery' && App.order['pay_type'] == 'card' ){ if( typeof App.order.tipHasChanged == 'undefined' ){ - App.order.tip = 15; - $('[name="pay-tip"]').val( App.order.tip ); + App.order.tip = 15; // Default value is 15 + wasTipChanged = true; + } } + if( wasTipChanged ){ + $('[name="pay-tip"]').val( App.order.tip ); + // Forces the recalculation of total because the tip was changed. + totalText = '$' + this.total(); + } if (App.restaurant.meetDeliveryMin() && App.order.delivery_type == 'delivery') { $('.delivery-minimum-error').show();