Using an External Script

One of the most versatile additions to Cart32 is the use of the Run External CGI Script under the Shopping Cart category, Order Processing subcategory, Run External Script 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:

  1. Configuration of the Cart32 web administration to run the external script
  2. 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.

 

Configuration:

There are a few steps that need to take place in order to configure the Cart32 web administration to run the script. These are:

  1. Under the Run External Script tab of the Shopping Cart category, Order Processing subcategory, make sure the Use Run External checkbox is checked to invoke the script during checkout.
  2. You have two options of what to set for the HTTP/HTML form method,these are POST or GET
  3. After this, you will need to actually specify at what URL the server-side script or CGI application is running at.
  4. Under the Script Parameters, you will need to configure what Cart32 will pass to the script or executable.
  5. Include order items in script 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.).
  6. 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.
  7. Click Add Parameter and it will be added to a list of parameters that need to be passed when the script is called.
  8. 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.
  9. Under the Output Information section, this will allow Cart32 to save the information returned from the script to a file on the server.
  10. Write CGI Output To A File, will allow Cart32 to save the output to a file from the script after execution
  11. 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.
  12. 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.
  13. CGI Output File Location These two allow you to select between the Cart32 directory or the full physical path, if elsewhere on the server.
  14. 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.

Log in