Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How To Override Core Javascript File? Rate Topic   * * * * * 1 votes

 
  • ooaykac
  • Senior Member
  • Members
  • Join Date: 22-Nov 12
  • 275 posts

Posted 15 December 2015 - 09:02 AM #1

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?



 
  • oleg.gorshkov
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 3081 posts

Posted 15 December 2015 - 09:05 AM #2

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


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE

Mega SEO Package - All you need for your SEO


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 18348 posts

Posted 15 December 2015 - 12:31 PM #3

- 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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • oleg.gorshkov
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 3081 posts

Posted 15 December 2015 - 02:30 PM #4

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

 

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


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE

Mega SEO Package - All you need for your SEO


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 18348 posts

Posted 15 December 2015 - 03:53 PM #5

{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 


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • oleg.gorshkov
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 3081 posts

Posted 16 December 2015 - 01:16 PM #6

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


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE

Mega SEO Package - All you need for your SEO


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 18348 posts

Posted 16 December 2015 - 03:42 PM #7

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • ooaykac
  • Senior Member
  • Members
  • Join Date: 22-Nov 12
  • 275 posts

Posted 23 December 2015 - 08:31 AM #8

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



 
  • alaa
  • Advanced Member
  • Trial users
  • Join Date: 18-Mar 18
  • 69 posts

Posted 17 May 2018 - 09:15 PM #9

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!