Zen Cart Logo
Forums / Code Collaboration / Extras folder Access to ZC functions

Extras folder Access to ZC functions

Views: 1,726

Results 1 to 4 of 4
7 May 2016, 3:13 PM
#1
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Extras folder Access to ZC functions

I've developed code in ZC to match customers names and addresses with names and addresses in a custom table so that customers who create an account and are in the custom table get a discount and access to other member benefits. There are lots of issues with matching names and addresses including first name nicknames, last name surnames, abbreviations for street, road, drive, East, etc., alias cities, and more. I'm working on a matching function that works pretty well I think, but would like to test it using a php program that reads a file of names and addresses, runs each through my matching function, and records the results.

If I develop a php program and put it in the extras folder in my development system, will it be able to access zen cart functions as well as functions in the extra_functions folder? Any other suggestions? This is kind of like a unit test without an IDE. DrByte's utilities in the extras folder gave me the idea. I wasn't sure his code accessed zen cart functions after a quick look.

7 May 2016, 5:45 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Extras folder Access to ZC functions

Yes, given that application_top loads all the files in the extra_functions folder, once application_top is loaded, you'll have access to all functions loaded by the system.

9 May 2016, 2:47 PM
#3
dave224 avatar

dave224

Zen Follower

Join Date:
Jun 2012
Posts:
481
Plugin Contributions:
0

Re: Extras folder Access to ZC functions

To accomplish application_top loading, just use an include statement? I've tried that, but I get a "file not found" error. This is the code:

include('Applications/MAMP/htdocs/zctest/includes/application_top.php');

This code is in the test routine located in the extras folder.

9 May 2016, 2:50 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Extras folder Access to ZC functions

Usually one uses a path that is relative to the directory in which the files are stored.

So if your script is stored in (and runs from) that zctest folder, the include (actually "require" is more correct, since it's "required", not merely try to include this) would be:

require('includes/application_top.php');