Agora Cart Check

The Agora cart_check.cgi script is a simple script that checks the contents of an Agora Shopping Cart. Since the script is small and standalone, it's easily incorporated into web sites and applications via Server Side Includes (SSI). This means you can have a "...items in cart" message on every page of your web site, not just the shop areas. cart_check.cgi will check the cart as defined in the browser cookie, or the CGI query string.

Installation of this script is pretty straight forward:

1. Download the script (see attachments)
2. Edit the script to ensure that:
2a. The location of Perl is correct in the first line of the script (for example, it might need to be "#!/usr/bin/perl" or "#!C:/perl/bin/perl").
2b. The variable definitions for $cart_dir, $empty_string, $oneitem_string and $manyitems_string are as you want them. If you're not sure, you can probably leave them as they are. They're documented in the script, and hopefully quite self-explanatory.
3. Upload the script (in ASCII) to the same directory as agora.cgi (probably cgi-bin/store) on your web site.
4. Ensure the file is set to permissions mode 755 (eg. "chmod 755 cart_check.cgi").

That's about it, it is usable as it is. You can test it by visiting http://yourserver/cgi-bin/store/cart_check.cgi with a browser. You should see "Basket is Empty". Now visit your online store, and add something to your basket, and then try the check again.

You'll notice that if you SSI include cart_check.cgi in ordinary web pages it always reports that the cart is empty. This is because the cookies used by Agora only refer to the store areas, and not the whole web site. To workaround this problem, it is possible to use the CGI query string when calling the cart_check.cgi script, or by patching the agora.cgi script slightly to make the cookies refer to the whole web site.

To patch agora.cgi, make a backup copy of it and open it in a text editor. Do a text search for the following lines:

sub SetCookies

    {<br />
    local(@test);<br />
    $cookie{'cart_id'} = &quot;$cart_id&quot;;<br />
    $domain = $sc_domain_name_for_cookie;<br />
    @test = split(/\./,$domain);<br />
    #if ($test[2] eq '') { $domain = '.' . $domain;}<br />
    $secureDomain = $sc_secure_domain_name_for_cookie;<br />
    @test = split(/\./,$secureDomain);<br />
    #if ($test[2] eq '') { $secureDomain = '.' . $secureDomain;}<br />
    ~~#FF0000: $path = $sc_path_for_cookie;~~<br />
    ~~#FF0000: $securePath = $sc_secure_path_for_cookie;~~<br />
    $secure = &quot;&quot;;<br />
    $now = time;<br />
    $twenty_four_hours = &quot;86400&quot;;<br />
    $cookie_hours = $sc_cookie_days * $twenty_four_hours;<br />
    $expiration = $now+$cookie_hours;<br />
    &amp;codehook(&quot;about_to_set_cookie&quot;);<br />
    if(!$form_data{'secure'}){<br />
      &amp;set_cookie($expiration,$domain,$path,$secure);<br />
     } else {<br />
      &amp;set_cookie($expiration,$secureDomain,$securePath,$secure);<br />


Change the lines shown in red above and add lines as follows:

#$path = $sc_path_for_cookie;

    #$securePath = $sc_secure_path_for_cookie;<br />
    $path=&quot;/&quot;;<br />

Now save the agora.cgi file and upload it to your web server. Any cookies in your browser will have to expire or be deleted, but once this is done, new cookies will be accessible across the whole site, including any ordinary pages that have SSIs in them.

Incidentally, if you don't like the idea of shopping cookies expiring in a couple of days time, then you can perform another patch to set $expiration to &quot;&quot; to make the cookies expire when the browser is closed. This may be a bit more user intuitive, or not, depending on your point of view.