One of the most versatile additions to Cart32 is the use of the Run External CGI Script
under the Enterprise tab inside the Cart32 web administration. Unfortunately, this is one of the more difficult features to enable for an inexperience developer. We will cover two parts for using this feature :
- Configuration of the Cart32 web administration to run the external script
- An example in PHP of how to access parameters passed from Cart32 to a server-side script
NOTE: Cart32 can call and pass parameters to any server-side script or compiled CGI Application,regardless of the programming language used to create the script.
There are a few steps that need to take place in order to configure the Cart32 web administration to run the script. These are:
- Under the Enterprise tab, make sure the Use Run External CGI checkbox is checked to invoke the script during checkout.
- You have two options of what to set for the HTTP/HTML form method,these are POST or GET
- After this, you will need to actually specify at what URL the server-side script or CGI application is running at.
- Under the CGI Parameters, you will need to configure what Cart32 will pass to the script or executable.
- Include order items in CGI values, will allow Cart32 to pass the individual items from the order to the script in the form of numbered parameters(e.g. Price1, qty2, etc.).
- The next section will allow for the setup of the order parameters themselves. For example, if you want to include the order date in the script you could use a parameter name of ordate. Then, from the dropdown on the right, select the #Order Date#value.
- Click Add Parameter and it will be added to a list of parameters that need to be passed when the script is called.
- NOTE: The values in the dropdown will be filled by Cart32 before being passed to your script. These are just placeholders to allow for the setup inside Cart32.
- Under the Output Information section, this will allow Cart32 to save the information returned from the script to a file on the server.
- Write CGI Output To A File, will allow Cart32 to save the output to a file from the script after execution
- NOTE:The script will not actually open another browser to show output, nor will it show HTML or formatting. Cart32 simply invokes the script, and captures the output to a file.
- CGI Output File Type These two choices allow for Cart32 to append to an existing file for the output (or create if not found) OR to create a new file for each time the script returns output.
- CGI Output File Location These two allow you to select between the Cart32 directory or the full physical path, if elsewhere on the server.
- CGI Output File/Directory This is the Full Path on the server where the output file is to be saved to.
Example in PHP:
This is a small server-side script written in PHP that shows how to handle Cart32 parameters and arguments when the script is run. All this example shows is handling item information, however the capability can be expanded to include any of the Cart32 parameters.
View the sample script