How To Override Core Javascript File?

Hi. I need to override core.js file in /js/tygh/ folder by using my addon.

I tried this:

/public_html/js/addons/my_addon/overrides/tygh/core.js But it didn't work.

Then I tried this:

/public_html/js/addons/my_addon/tygh/core.override.js

It also didn't work. What is the correct methos to do this?

There is no way to override js.

You can override tpl which includes this js.

Try overriding design/themes/[YOUR THEME]/templates/common/scripts.tpl

- Try to create the following file:

design/themes/YOUR_THEME/templates/addons/my_changes/overrides/common/scripts.tpl

- Copy the content of the design/themes/YOUR_THEME/templates/common/scripts.tpl file to it

- Replace:

{script src="js/tygh/core.js"}

with

{script src="js/addons/my_changes/core.override.js"}

- Clear cache and check the result

{script src="js/tygh/core.override.js"}

it should be in js/addons/[ADD-ON]/ folder

{script src="js/tygh/core.override.js"}

it should be in js/addons/[ADD-ON]/ folder

It should not, but this is right way. Corrected

Yes, it should not, but all add-on's js files are located there. Just for keeping order.

ooaykac, did our and simtedev's answer help you?

Thanks to everyone. Yes, simtechdev's answer helped me. It works.

There is no way to override js.

You can override tpl which includes this js.

Try overriding design/themes/[YOUR THEME]/templates/common/scripts.tpl

- Try to create the following file:

design/themes/YOUR_THEME/templates/addons/my_changes/overrides/common/scripts.tpl

- Copy the content of the design/themes/YOUR_THEME/templates/common/scripts.tpl file to it

- Replace:

{script src="js/tygh/core.js"}

with

{script src="js/addons/my_changes/core.override.js"}

- Clear cache and check the result

It should not, but this is right way. Corrected

Hi, I have a question regarding this. I want to edit one line in js\tygh\core.js

When we override this file in using tpl, does this mean that the new file core.override.js must contain all the functions on the original file core.js?

Can we override a specific function only instead of overriding the whole core.js file?

If not, What if future CS-Cart upgrades contain code modification/enhancements to this file. In this case, I will not get benefit from this as my file stays the same.

Can you please clarify?

Thanks!