#!/usr/bin/perl use strict; require 5.003; use aolapi; my $carturl = 'cart.pl'; print "Content-type: text/html\n\n"; header(); if (!aolapi::init()) { print "Unable to initialize aolapi"; footer(); exit; } my $parm = $ENV{'QUERY_STRING'}; if ($parm ne undef) { my @args = split(/&/, $parm); my %INPUT; foreach my $arg (@args) { my ($name, $value) = split(/=/, $arg); $value =~ s/%0D%0A/\n/g; $value =~ s/%0A%0D/\n/g; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $INPUT{$name} = $value; } my $accid = $INPUT{'accid'}; my %accnt = aolapi::getaccnt($accid); my $name = 'customer'; $name = "$accnt{'name'} $accnt{'lname'}" if $accnt{'name'} ne undef; print "
Dear $name,

Thank you for shopping in our store.

Your order:
\n" . "\n"; my %cart; my $total = 0; foreach my $item (split(/ /, $INPUT{'cart'})) { my ($prodid, $qty) = split(/:/, $item); my %product = aolapi::getproduct($prodid); my $itemprice = $product{'setup'}; $itemprice = -$itemprice if $product{'billtype'} eq 'DB'; print "\n"; $total += $itemprice * $qty; } print "
DescriptionQtySubtotal
$product{'description'}$qty" . sprintf("%.2f", $itemprice * $qty) . "
Total" . sprintf("%.2f", $total) . "


\n"; } my @prodlist = aolapi::listproducts(); if (!@prodlist) { print "In order to use this demo please create at least one product of invoice type"; footer(); exit; } print "
Product selection form
\n
\n" . "\n" . "\n" . "\n" . "
\n"; print "
View cart form
\n" . "
\n" . "\n" . "\n" . "
\n"; print "
Check out form
\n" . "
\n" . "\n" . "\n" . "
\n"; sub header { print "

Shopping Cart Demo

\n"; } sub footer { print "
\n"; }