Download Perl Scripts

ESC - Excel Shopping Cart 90820ESC - Excel Shopping Cart - $0 Version 90820
Add to Cart

demo/see it work
RSS Feed
ESC - Excel Shopping Cart
By Jason Silver of

Using ESC As Your Shopping Cart

One of the biggest advantages to ESC is a very quick set up time and an ease of management. This is because
ESC is based on an Excel spread sheet. The data for the cart is a tab-delimited spreadsheet which can be
edited in Excel, pasted into a text editor, and uploaded to your server at anytime.

Another great advantage to ESC is the flexibilty of formatting and purposing. The data can have any number
of columns, and can be displayed anyway you want. You can search specific fields easily, and create your
own templates in minutes.

It allows for multiple pricing options for each product since it can hide duplicates automatically if you
so desire. Examples are included in the sample database and templates.

You can have any number of images so that thumbnails are simple to set up.

You can create your own custom formulas for processing price; each product can have it's own shipping
amount; you can set up any payment system to work with it, or just have it send you an email when
an order is placed.

It's completely flexible!
Understanding the Cart

There are some conditions to make this cart work.

1. The names of the columns (fields) must be specified in the first row, separated by tabs - they should
not have spaces.
2. The first column must be entitled ID. If it is not, the script will automatically create an ID column
and save the column in a new file, replacing your old file.
3. There must be a 'Name' column. This is the name of the product (no quotes).
4. There must be a 'Price' column. This is the price of the product. (again, no quotes).
4. If each item has a different shipping amount, then create a column called 'Shipping'
5. All image fields must begin with 'Image,' for example, 'ImageURL1' or 'ImageThumb' etc. This is the URL to
the image in question.
The image is assigned a class name for CSS. The class name is always the field name. So for
the column 'ImageURL' all images from that column will belong to that class. This way you can
specify an image width, and other style options in the CSS file.
6. There are three template files for this shopping cart. They are called...
- header.txt
- footer.txt
- table_view.txt
...The table_view.txt file is especially important, because this is where you specify the
look of your data: which fields are displayed and how they are laid out. If you create a
column (a field) called LastName, then everywhere you want last name to appear in the row
you enclose it with double percentage marks: %%LastName%%. Case is important.
Look at the sample table_view.txt file for a good example.

Besides the variables in your database there are some other variables available for your use:
%%AlternateRows%% - A class name for alternating colours etc. in your rows. The two classes are
named Row1 and Row2
This displays a counter to show 1. 2. 3. etc down the rows in your table.

7. Default Setup Variables:

The name of your site (at the top of each page and appears in emails:
my $site_title = "";
The path (not the URL) to your spreadsheet file... this must be a tab separated spreadsheet:
my $path_to_tsv_spreadsheet = $ENV{'DOCUMENT_ROOT'}."/cgi-bin/ESC/price_spreadsheet.csv";
The URL to this script:
my $url_to_this_script = "";
The paths to your templates files:
my $header_file = $ENV{'DOCUMENT_ROOT'}."/cgi-bin/ESC/header.txt";
my $footer_file = $ENV{'DOCUMENT_ROOT'}."/cgi-bin/ESC/footer.txt";
my $table_view_template = $ENV{'DOCUMENT_ROOT'}."/cgi-bin/ESC/table_view.txt";
Whether or not to hide duplicate items:
my $hide_duplicate_data = 1;
Which fields (columns) to not hide if there are duplicates: (space separated)
my $dont_hide_these_columns = "Type Dimensions Price NumberIncluded Type1 Type2";
The URL to the style sheet. It cannot be in the cgi-bin:
my $url_to_stylesheet = "/esc_stylesheet.css";
How many items to show on each page?
my $items_per_page = 20; # how many items on each page
The path to SENDMAIL on your Unix/Linux server:
my $emailprog = "/usr/lib/sendmail";
The seller's email (appears in emails):
my $seller_email = '';

8. Custom formulas
There are two subroutines which you can create for customizing calcualtions in the script. The are
custom_cart_formula and checkout:

sub custom_cart_formula{
# Without this routine, the cart will figure cost by multiplying product Price X number in cart.
# If you don't need this custom_cart_formula, do the following:
return (0);

If you do want to use this cart, for example, to multply Price X NumberIncluded in product, use
a formula like this:
my ($ID) = @_;
my $new_price = &round_off_to_dollar_digits($DATABASE{"$ID,NumberIncluded"} * $DATABASE{"$ID,Price"} * $CART{$ID});
return ($new_price);

The checkout subroutine can send payment to PayPal or any other payment system, but if you don't know Perl
you may need some help setting it up.

sub checkout{
my ($total_amount) = @_;
# send payment info by email or to PayPal etc.
# Ask for user's email address, name, and payment preference?
# If we already have that, send it.
if (!length($FROMWEB{'emailto'})){
# Don't have the buyer's email address, so let's get it
print qq~
<h2>Thanks for your business.</h2>
<p>Enter your information below to continue:</p>
Email Address: <input type=text name=emailto><br/>
Full Name: <input type="text name=fullname><br/>
<input type=submit name=checkout value=Finish>
# make sure the fields in email aren't filled with new lines etc. Keep safe characters only.

my $from_email = &clean_string($FROMWEB{'emailto'});
my $full_name = &clean_string($FROMWEB{'fullname'});
my $message = &make_cart_into_string;
$message = qq~$full_name ($from_email) has submitted an online order.\n\n~.$message;

open(MAIL,"|$emailprog -t");
print MAIL "To: $site_title <$seller_email>\n";
print MAIL "From: $site_title <$seller_email>\n";
print MAIL "Reply-To: $full_name <$from_email>\n";
print MAIL "X-Mailer: ESC -\n";
print MAIL "Subject: Purchase Made at $site_title\n\n";
print MAIL "$message\n\n";
print qq~
<h2>Thank you $full_name</h2>
<p>An email has been sent to us, and we will contact you shortly at $from_email.</p>
my $next_link = $FROMWEB{'fm'} + $items_per_page;

Installing ESC

To get this running on the file server, ensure that Perl is available.
Set the correct path to Perl in the first line of ESC.cgi

Set all the variables to their correct values for your web server.

Upload all of the files to a new folder in your cgi-bin. CHMOD this folder to 755.

CHMOD ESC.cgi to 755.

Upload the esc_stylesheet.css to a folder which is accessable from the web, such
as the root of your www or public_html directory. Be sure the CSS variable
$url_to_stylesheet has the correct URL in it at the top of the ESC.cgi script as well.

Open the script ESC.cgi from your web browser.

top next download faq demo/see it work xml pad file RSS Syndication OPML List - All Programs


FileCABINET Script - Create a File Download section on your site.

In the Spotlight

Random Image $0.00
Add to Cart
 This simple script searches a special directory for images, then displays a random one every time the page is loaded.
[more & download links]

What People Say

Bible in One Year $0
Add to Cart Just what I've been looking for!
Thanks for such a great script!

[more & download links]

Post Page Comment