How To Add Custom Javascript With My Changes Addon

For example, you want to add specific jQuery plugin (myscript.carousel.min.js).

The tutorial is actual for CS-Cart and Multi-Vendor 4.x

1. Make sure that the status of the My changes add-on is Active ( Add-ons -> Manage Add-ons )

2. Put the myscript.carousel.min.js file to the CSCART_DIR/js/addons/my_changes directory
3. Create the CSCART_DIR/design/themes/[your theme]/templates/addons/my_changes/hooks/index/scripts.post.tpl file with the following content

{script src="js/addons/my_changes/myscript.carousel.min.js"}
4. Clear the cache ( Administration > Storage > Clear cache )
5. Check the result

See also:
- [url="http://forum.cs-cart.com/topic/37510-how-to-add-custom-css-with-my-changes-addon/"]How To Add Custom Css With My Changes Addon[/url]
- [url="http://forum.cs-cart.com/topic/38177-how-to-add-a-new-carrier/"]How To Add A New Carrier[/url]
1 Like

#2 should



be design/themes/[yourtheme]/templates/addons/my_changes/hooks/index/scripts.post.tpl[color=#282828][font=arial, verdana, tahoma, sans-serif] file [/font][/color]



#3 not required for a custom JS

[quote name='requincreative' timestamp='1415315214' post='196320']

#2 should



be design/themes/[yourtheme]/templates/addons/my_changes/hooks/index/scripts.post.tpl[color=#282828][font=arial, verdana, tahoma, sans-serif] file [/font][/color]



#3 not required for a custom JS

[/quote]



Thanks, Jeremy. It was a hard day yesterday. Corrected

You don't need to clear storage cache for custom JS, however the way he described it you do indeed need to clear the cache, because the scripts.post.tpl needs to be reloaded in order for the new "myscript.js" to be loaded.

Are you reallly affirming a year old post?

You don't need to clear storage cache for custom JS, however the way he described it you do indeed need to clear the cache, because the scripts.post.tpl needs to be reloaded in order for the new "myscript.js" to be loaded.

You can always try. The compiled js file should be recreated to include new js file. So we ask you to clear the cache

Hi there!

I just tried this, but it didn't work. I cleared the cache, too.

The one thing I didn't have before is a "js" folder inside my theme folder. I had to create that, then create the addons and my_changes folders inside that.

That was the only part that wasn't really apart of the steps up top. Thoughts?

js folder is in the root of your store. If you want to put JS in a different location, then you must ensure that your smarty script tag references the new location. Generally addon js scripts should go in js/addons/[addon name]/nameofyourscript.js

Hi there!

I just tried this, but it didn't work. I cleared the cache, too.

The one thing I didn't have before is a "js" folder inside my theme folder. I had to create that, then create the addons and my_changes folders inside that.

That was the only part that wasn't really apart of the steps up top. Thoughts?

tbirnseth is right. I have corrected the instruction. Hope this will help you.

hello,

can someone check if workarround is working with 4.4.3 (trial)

regards

What workaround?

hello,

can someone check if workarround is working with 4.4.3 (trial)

regards

Solution from post #1 will work correctly on 4.4.3 trial version

i'm having this strange issuse adding some js from

https://basehold.it/

it removes the first banner image...

Then you probably have a conflict between variable/function names that it uses and ones used in cs-cart or other included JS. Does your browser console inspector shed any light?

I know this is an old post, but I'm wondering if this method still works with the newest version of CS-Cart 4.6.3? More specifically, Multi-Vendor.

I followed the instructions in the first post and the javascript files are not being added when I view the source of the page in Chrome.

Did you clear the cache?

Did you clear the cache?

Yes, both in the cs-cart admin and on my host. I am using a purchased Theme, if that makes a difference?

Yes, both in the cs-cart admin and on my host. I am using a purchased Theme, if that makes a difference?

Hello!

Please make sure that the My changes add-on is enabled.

Yes, both in the cs-cart admin and on my host. I am using a purchased Theme, if that makes a difference?

Try to find your code in the common .js file which is complied from all included files

Try to find your code in the common .js file which is complied from all included files

I'm assuming this is the scripts.tpl in the design/themes/[my theme]/templates/common folder? If so, my js files are not linked in there.

Would it affect it if I'm using a third party purchased theme?