Created
November 2, 2015 13:10
-
-
Save torunar/87e93cf92a9adde5650c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/js/tygh/checkout.js b/js/tygh/checkout.js | |
index 807aef7..8c36238 100644 | |
--- a/js/tygh/checkout.js | |
+++ b/js/tygh/checkout.js | |
@@ -18,8 +18,26 @@ | |
} | |
function displayRecalculate(form) { | |
- form.find(place_order_buttons_selector).hide(); | |
- form.find(recalculate_buttons_selector).show(); | |
+ var changed_groups = { | |
+ user_data: false | |
+ }; | |
+ | |
+ form.find(inputs_selector).each(function(){ | |
+ var elm = $(this); | |
+ if (elm.attr('type') != 'hidden' && form_values[elm.attr('name') + '_' + elm.attr('id')] != getVal(elm)) { | |
+ var elm_name = elm.attr('name'); | |
+ if (elm_name) { | |
+ var elm_group = elm_name.split('[')[0]; | |
+ changed_groups[elm_group] = true; | |
+ } | |
+ } | |
+ }); | |
+ | |
+ // require recalculate only when user data changed | |
+ if (changed_groups['user_data']) { | |
+ form.find(place_order_buttons_selector).hide(); | |
+ form.find(recalculate_buttons_selector).show(); | |
+ } | |
} | |
function saveFormValues(form) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment