Jump to content

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

How To Add Custom Javascript With My Changes Addon Rate Topic   * * * * * 2 votes

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

Posted 06 November 2014 - 03:58 PM #1

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:
- How To Add Custom Css With My Changes Addon
- How To Add A New Carrier

DISCOUNTS UNTIL APRIL, 27! 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 305     Multi-Vendor              USD 1150    CS-Cart RU                         21500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 505      CS-Cart RU + UniTheme    33000 руб.


 

Posted 06 November 2014 - 11:06 PM #2

#2 should

be design/themes/[yourtheme]/templates/addons/my_changes/hooks/index/scripts.post.tpl file

#3 not required for a custom JS

Jeremy
Requin Creative Group
CS-Cart License | CS-Cart Addons


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

Posted 07 November 2014 - 09:51 AM #3

#2 should

be design/themes/[yourtheme]/templates/addons/my_changes/hooks/index/scripts.post.tpl file

#3 not required for a custom JS


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

DISCOUNTS UNTIL APRIL, 27! 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 305     Multi-Vendor              USD 1150    CS-Cart RU                         21500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 505      CS-Cart RU + UniTheme    33000 руб.


 
  • truskydesign
  • Newbie
  • Authorized Reseller
  • Join Date: 16-Jan 12
  • 4 posts

Posted 06 October 2015 - 10:29 PM #4

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.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10481 posts

Posted 07 October 2015 - 12:20 AM #5

Are you reallly affirming a year old post?


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


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

Posted 07 October 2015 - 09:32 AM #6

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


DISCOUNTS UNTIL APRIL, 27! 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 305     Multi-Vendor              USD 1150    CS-Cart RU                         21500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 505      CS-Cart RU + UniTheme    33000 руб.


 

Posted 14 October 2015 - 11:05 PM #7

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
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10481 posts

Posted 14 October 2015 - 11:57 PM #8

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


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


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

Posted 15 October 2015 - 08:40 AM #9

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.


DISCOUNTS UNTIL APRIL, 27! 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 305     Multi-Vendor              USD 1150    CS-Cart RU                         21500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 505      CS-Cart RU + UniTheme    33000 руб.


 
  • demeldoo
  • Senior Member
  • Members
  • Join Date: 27-Jul 12
  • 891 posts

Posted 14 February 2017 - 02:23 PM #10

hello,

 

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

 

regards



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10481 posts

Posted 15 February 2017 - 01:28 AM #11

What workaround?

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


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

Posted 15 February 2017 - 06:42 AM #12

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


DISCOUNTS UNTIL APRIL, 27! 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 305     Multi-Vendor              USD 1150    CS-Cart RU                         21500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 505      CS-Cart RU + UniTheme    33000 руб.


 
  • demeldoo
  • Senior Member
  • Members
  • Join Date: 27-Jul 12
  • 891 posts

Posted 24 February 2017 - 12:08 PM #13

i'm having this strange issuse adding some js from 

 

https://basehold.it/

 

it removes the first banner image...



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10481 posts

Posted 24 February 2017 - 07:35 PM #14

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?


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • SwimShady
  • Advanced Member
  • Members
  • Join Date: 05-Aug 14
  • 73 posts

Posted 23 November 2017 - 07:58 PM #15

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.



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10481 posts

Posted 23 November 2017 - 08:10 PM #16

Did you clear the cache?

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • SwimShady
  • Advanced Member
  • Members
  • Join Date: 05-Aug 14
  • 73 posts

Posted 23 November 2017 - 09:19 PM #17

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?



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

Posted 24 November 2017 - 05:50 AM #18

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.


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE
Get more traffic with JSON-LD for SEO


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

Posted 24 November 2017 - 06:16 AM #19

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


DISCOUNTS UNTIL APRIL, 27! 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 305     Multi-Vendor              USD 1150    CS-Cart RU                         21500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 505      CS-Cart RU + UniTheme    33000 руб.


 
  • SwimShady
  • Advanced Member
  • Members
  • Join Date: 05-Aug 14
  • 73 posts

Posted 24 November 2017 - 04:30 PM #20

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?