Issues with Advanced Shipper js files when accessing methods in admin since upgrading
I'm upgrading a site to version 1.5.7 and Advanced Shipper, which on 1.5.6 was working perfectly is now broken.
On inspecting the console log I'm seeing " Uncaught SyntaxError: Unexpected token '<' " The code line where it reports this error is in a js file located in admin/includes/javascript
The code line it throws the error on is
var session_language_id = <?php echo $_SESSION['languages_id']; ?>;
I've got other instances of the same error in different files, for instance it has taken a dislike to the opening php tag around the comments at the very start of another js file.
Given that this should be a valid code format, can anyone shed any light on whether or not any changes in the 1.5.7 admin core are causing this issue as it's got me stumped!
Re: Issues with Advanced Shipper js files when accessing methods in admin since upgra
.js files can't parse PHP code if loaded directly by the browser
This has nothing to do with any specific Zen Cart version.
The only thing about Zen Cart 1.5.7 vs prior versions is the introduction of a directory to store javascript files that could get automatically loaded. But that doesn't change the fact that .js files DO NOT parse PHP code when loaded directly from the server.
Contact whoever is writing the shipper plugin you're using to find out why it's working differently than expected.
Re: Issues with Advanced Shipper js files when accessing methods in admin since upgra
Quote:
Originally Posted by
DrByte
This has nothing to do with any specific Zen Cart version.
Wrong, it had everything to do with a specific zen cart version.
Zen Cart 1.5.7 loads the files in admin/includes/javascript automatically rather than them being loaded when called by the module. This was the cause of the issues. The files have had to be removed from the javascript directory and modifications made to suit the new file location.
Re: Issues with Advanced Shipper js files when accessing methods in admin since upgra
Hmm ... You are correct: it does load all *.js files in that directory.
That doesn't change the fact that .js files should not contain PHP code. Make them .php files if you want them treated as PHP.
Re: Issues with Advanced Shipper js files when accessing methods in admin since upgra
I'm using the same shipping module, it was originally written by CEON, but is no longer available in the Zen Cart plugin directory. A commercial version is available, but the changelog gives no info what fixes were made so I'm unsure if buying the commercial version will help.
The old module from 2011 does indeed use PHP in a JS file; and whilst this isn't how we would do things nowadays, a quick fix is to do what Strelitzia suggested.
Move the following 4 JS files from /admin/includes/javascript/ to a new folder, I've used /admin/includes/advshipper_js/
advshipper_method_config.js
advshipper_product_selector.js
advshipper_region_config.js
advshipper.js
NB: When I say "move", I mean to copy into the new folder & then delete the from old. JS files are indeed auto loaded, so just copying without deleting wont' work.
And then update the file path in these 4 files in /admin/
advshipper_method_config.php
advshipper_product_selector.php
advshipper_region_config.php
advshipper.php
It''s a quick way to continue using this shipping module, and CEON's code appears to hold up well.
with kind regards, Edith
Re: Issues with Advanced Shipper js files when accessing methods in admin since upgra
Conor Kerr (ceon) always had this module as commercial. The loss of Conor was a huge blow to the community of Zen Cart. Fortunately, his site is still up and run by the family. The site currently has version 6.06 available and often will allow an upgrade if you have a record of your original purchase.
Might want to check with them