Jump to content
thirty bees forum
  • 0

Override tools.js


Question

Posted

I have a small js modification stored in the core code root/js/tools.js path.  I was wondering if an override could be applied to js files similar to the class and controller files so that I don't need to update the file each time the shop is updated.

Override JS questions:

1.  Can JS files use an overrride?

2.  If so, can just the changed function be added in the override, or does an entire file required to duplicate and override the original?

3.  Where should the override file be saved? (e.g. in root/override/js/tools.js or root/themes/mytheme/js/tools.js

 

The tools.js modification starts on line 375 and is comments out as follows:

function checkCustomizations() {
  var pattern = new RegExp(' ?filled ?');

  if (typeof customizationFields != 'undefined') {
    for (var i = 0; i < customizationFields.length; i++) {
      /* If the field is required and empty then we abort */
/**** line below replaced for removing save
      if (parseInt(customizationFields[i][1]) == 1 && ($('#' + customizationFields[i][0]).html() == '' || $('#' + customizationFields[i][0]).text() != $('#' + customizationFields[i][0]).val()) && !pattern.test($('#' + customizationFields[i][0]).attr('class'))) {
****/
    if (parseInt(customizationFields[i][1]) == 1 && ($('#' + customizationFields[i][0]).val() == '')) {

        return false;
      }
    }
  }
  return true;
}

 

3 answers to this question

Recommended Posts

  • 0
Posted

I am not totally sure. Maybe it works to create an override.js file and add the whole function. Then make sure that override.js is loaded after tools.js. 

It might work, but I really haven't used this before. Let me know 🤗

  • 0
Posted

You can place your own javascript file inside your "theme_folder/js/autoload" and the file should be loaded automatically.

Just override the entire function like @wakabayashi mentioned and I believe it should work, because Javascript allows overriding functions.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...