No announcement yet.

question about overriding common files

  • Filter
  • Time
  • Show
Clear All
new posts

  • question about overriding common files

    According to 3dcart's knowledge base:

    The common folder (web/assets/templates/common) is maintained and updated by 3dcart and therefore cannot be written to. However, if there's a common template file that you'd like to edit, simply download a copy of it via FTP and upload it to your site's theme folder. Your store will automatically use it instead.
    I've worked with customizing these files many times so I understand the above statement, but now I'm interested in editing a file in common/js

    If I copy the file into my_template/js and make edits to it, I don't see the changes apply on my web site.

    So I'm guessing your template files override common files if they are right there in the root of your template folder, and not in those sub folders.

    Is this true? Can anyone confirm that for me?

    Thanks so much,

    Cookie Decorating Simplified

  • #2
    I don't think I've ever tried to over-ride a common JS file actually.

    In my frame.html, it is calling the JS files explicitly from the common folder:

    <script type="text/javascript" src="assets/templates/common/js/utilities.js"></script>
    So you would just need to point that at your own version.


    • #3
      you can definitely override the js files as well, but you need to change the paths. unlike the html files (which the server handles via routing), the javascript files are linked to directly in the template files.

      for example. if you want to override the utilities.js file, (i think frame references the file) you would change the reference path from assets/templates/common/js/utilities.js to match the path for your template to assets/templates/[template]/js/utilities.js in the actual frame.html template html.

      the server handles html routing (its a bit lower level than linking to resources) but you'll always find a link somewhere to the js and css files within your template html.


      • #4
        While you could copy the whole file over and make your edits, it may be more efficient to redefine the individual functions you want changed in a seperate script placed after utilities.js. That way the others will stay up to date with 3dcart

        HTML Code:
        <script type="text/javascript" src="assets/templates/common/js/utilities.js"></script>
        //If you wanted to change the Validator function 
        var Validator = function() {
          //Your fancy new validator function code would go in here

        JES Restaurant Equipment


        • #5
          Great replies, thanks! Yes, if the file is being referenced directly, that will be a good piece of information as I continue to muck around.

          Thanks again.

          Cookie Decorating Simplified


          • #6
            Well, I can't find any files that reference the .js file I believe needs to be adjusted. I did a search through all of the common files and didn't find anything. I believe the file that needs to be changed is js/quick_view.js

            Any other thoughts?


            Cookie Decorating Simplified


            • #7
              well, I figured out how to fix my specific problem. I don't think you can override this js subdirectory, but I did fix it by making another call to the file in the frame.html file.

              You can read details in this post:

              Thanks for your help.

              Cookie Decorating Simplified