Hello,
I have just made some new scripts to automatically load address when entering postal code in create new account and address book pages. It has been done on Zen Cart 1.58 and PHP 8.2 and works fine but I am not happy with the way js scripts are loaded and I am not sure either if I put them at the best place. First the actual structure is like this:
Javascript files are in 'includes/templates/template_default/jscript/' folder.
Css files are in 'includes/templates/template_default/css/' folder.
Ajax php script is in 'includes' folder.
Css and Javascript files are loaded by these lines placed at the end of 'tpl_modules_create_account.php' and 'tpl_modules_address_book_details.php'.
Code:
<link rel="stylesheet" type="text/css" href="includes/templates/template_default/css/jquery.powertip.css" />
<script src="includes/templates/template_default/jscript/jquery.powertip.min.js"></script>
<script src="includes/templates/template_default/jscript/jquery.powertip.js"></script>
<script src="includes/templates/template_default/jscript/jscript_postcode.js"></script>
What it does:
When customer enter postal code in a form an ajax request is sent to a PHP script that retrieve state, city and local area (street) name from database. Result is then parse into form fields.
Here are my questions:
Is there a way to load these scripts in header (or beginning of body) of each page without touching template files?
About connection to database from a simple script (AJAX called), is it possible to use database constants in 'configure.php'? I tried this:
Code:
require_once 'configure.php';
but it did not work.
Bookmarks