Skip to content

Instantly share code, notes, and snippets.

@torunar
Created November 2, 2015 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torunar/87e93cf92a9adde5650c to your computer and use it in GitHub Desktop.
Save torunar/87e93cf92a9adde5650c to your computer and use it in GitHub Desktop.
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