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

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

Posted 24 November 2017 - 08:38 PM #21

A custom theme could impact it if it does not support the hooks for 'scripts'.  However, I would expect that if that were the case that you'd have all sorts of problems.

 

Verify that you in fact have a js/addons/my_changes/your_script_name.js file in place.

Add the following line to your scripts.post.tpl file:

<script type="text/javascript">
console.log("Loaded scripts.post.tpl");
</script>

and add this to your js/addons/my_changes/your_script_name.js file:

<script type="text/javascript">
console.log("Loaded JS file");
</script>

 

Clear your cache by manually removing/moving var/cache.

Clear your browser cache too.

 

Then open the browser inspector for your site by right-clicking and selecting "inspect".

You should see the messages in the console area related to the files that have loaded.

 

If not then either my_changes is not active or you have a typo in the pathname to the scripts.post.tpl file.


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
  • 17267 posts

Posted 27 November 2017 - 05:40 AM #22

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?

 

No, check source code for similar file

 

http://prntscr.com/hfptaf


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 руб.


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

Posted 27 November 2017 - 07:01 PM #23

Thanks tbirnseth & eCom.  I figured out the issue.  The first issue I had was that it wasn't showing up in my source code of the page so I thought it wasn't getting included, but then I looked for that compiled "script-[random number].js" file that you mentioned eCom, and it was all in there.

 

And the reason it wasn't working, is because there seemed to have a conflict with some of the other javascript code. It's all fixed and it works fine now.

 

Thanks guys!



 
  • judoscott
  • Advanced Member
  • Members
  • Join Date: 19-Mar 16
  • 64 posts

Posted 05 March 2018 - 08:23 PM #24

Do not use the var/theme_repository/basic/templates/addons/NAME ?

 

I asked in a separate thread about this.. The var directory seems redundant



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

Posted 05 March 2018 - 09:08 PM #25

The var/themes_repository area is for INSTALLATION of an addon.  For instance, any theme based on the 'responsive' theme will have templates loaded from var/themes/responsive....  Once an addon is installed, then any changes to the theme templates should be done in the design/themes/[YOUR THEME]/ directory structure.  But if you uninstall and addon and reinstall it, the theme templates for the addon will be removed and then reloaded from the var/themes_repository/responsive area.

 

Themes NOT based on the responsive theme will not have addons automatically install templates that are distributed in the var/themes_repository/responsive directory structure.  Manual copying will need to occur.  Some themes do this automatically within the theme installation itself, but there is no standard on how that's to be done.


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
  • 17267 posts

Posted 06 March 2018 - 06:49 AM #26

Also If you want to distribute your addon, installation package should contain store-front templates in var/theme_repository/THEME directory. If your module is used on your store only, there is no need to use this directory


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 руб.


 
  • judoscott
  • Advanced Member
  • Members
  • Join Date: 19-Mar 16
  • 64 posts

Posted 06 March 2018 - 01:16 PM #27

That's exactly what I have concluded as well. The directory layout for addons is just awful. Too much trivia needed to keep it operating properly,.



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

Posted 06 March 2018 - 07:11 PM #28

That's exactly what I have concluded as well. The directory layout for addons is just awful. Too much trivia needed to keep it operating properly,.

We have long argued for a single root for addons (php, templates, JS, etc.)....

But once you get used to it, and have setup a build environment to pull it into a proper archive, it's not too bad.

 

But once an addon is installed, all template stuff is in /design and everything else is in a static location.  It's really only the template area that are annoying.


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.