#!/usr/local/bin/perl
##############################################################################
# IntraLinks ShoppingCart Version 2.6
# Copyright 2000 IntraLinks Corporation
# Coded by Matt Champneys mchampneys@intralinkscorp.com
# Please direct comments or bug reports to mchampneys@intralinkscorp.com
#
# This program may be used and modified free of charge by anyone so long as
# this copyright notice is included. By using this code you agree to
# hold IntraLinks Corporation free from any liability that might arise
# from it's use. You may not sell or redistribute this code without prior written
# consent from IntraLinks Corporation
require "config.pl";
###########################################################
### program start
$top_page=top_page($template_file);
$bottom_page=bottom_page($template_file);
# get input if any
&get_data;
# Clean up the customer folder
$customer_time=86400*$customer_days;
&customer_cleanup;
# check to see if user has established ID. If not, establish one
if ($FORM{'uid'} eq "") {
# get the cookie
@cookievalues=split(/;/,$ENV{'HTTP_COOKIE'});
foreach $value (@cookievalues) {
if ($value=~/storecustomer=/) {
@cookie=split(/=/,$value);
$FORM{'uid'}=$cookie[1];
chomp($FORM{'uid'});
}
}
# no cookie data? Establish one
if ($FORM{'uid'} eq "") {
$FORM{'uid'}=&key_counter;
print "Set-Cookie: storecustomer=$FORM{'uid'}; path=/; expires=Tue, 04-Oct-2061 12:00:00 GMT;\n";
}
#check to see if there is a customer file and if not, create one
if (!open(IN,"$customer_folder/$FORM{'uid'}.txt")) {
open(OUT,">$customer_folder/$FORM{'uid'}.txt");
print OUT "";
close(OUT);
}
}
$customer_file="$customer_folder/$FORM{'uid'}.txt";
# send content header right away
print "Content-type: text/html\n\n";
## If no action is specified, show search page
if ($FORM{'action'} eq "") {
print qq| $top_page $title_front Revisar Tienda $title_back
Use una de las siguientes opciones de busqueda
$bottom_page |;
}
## if action is search display search results
if ($FORM{'action'} eq "search") {
open(IN,"$product_file");
while(){
@field=split(/\|/,$_);
if ($FORM{'keyword'} ne "") {
if (/$FORM{'keyword'}/i) {
$results[$z]=&short_display;
$z++;
if ($z==1) {$first_sku=$field[0];}
}
}
if ($FORM{'category'} ne "") {
if ($field[5] eq $FORM{'category'}) {
$results[$z]=&short_display;
$z++;
if ($z==1) {$first_sku=$field[0];}
}
}
if ($FORM{'listall'} ne "") {
$results[$z]=&short_display;
$z++;
if ($z==1) {$first_sku=$field[0];}
}
} # end of while loop
close(IN);
$z="";
if ($FORM{'category'} ne "") {
$results_title="$title_front $FORM{'category'} $title_back ";
} else {
$results_title="$title_front Resultados de
la búsqueda $title_back ";
}
$array_length=@results;
if ($reverse_order eq "Yes") {@results=reverse(@results);}
# if there is only one result, display the link, otherwise display the thumbnail page
if ($array_length==1) {
$FORM{'sku'}="$first_sku";
$FORM{'action'}="link";
} else {
# thumbnail page
$FORM{'keyword'}=~s/ /\+/g;
$FORM{'category'}=~s/ /\+/g;
$FORM{'skucategory'}=~s/ /\+/g;
if ($FORM{'startlist'} eq "") {$FORM{'startlist'}=0;}
$items_per_page=$display_rows * $display_columns;
$next_page_start=$FORM{'startlist'}+$items_per_page;
$prev_page_start=$FORM{'startlist'}-$items_per_page;
if ($prev_page_start >= 0) {
$previous=qq|<- Previous Page |;
}
if ($next_page_start < $array_length) {
$next=qq|Next Page -> |;
}
$number_displayed=$array_length-$FORM{'startlist'};
if ($number_displayed > $items_per_page) {$number_displayed=$items_per_page;}
$number_pages=int($array_length/$items_per_page);
$dec_number_pages=($array_length/$items_per_page);
if ($dec_number_pages > $number_pages) {$number_pages++;}
if ($FORM{'startlist'}==0){$number_display_pages=1;} else {$number_display_pages=int($FORM{'startlist'}/$items_per_page)+1;}
print qq| $top_page $results_title $array_length items encontrados. Mostrando Página $number_display_pages de $number_pages
$font $previous | $font $next |
|;
$y=$FORM{'startlist'};
for($x=0;$x<$display_rows;$x++) {
print "";
for($z=0;$z<$display_columns;$z++) {
print "$results[$y]";
$y++;
}
print "
";
}
print qq|
$font $previous | $font $next |
$statgraphic
$bottom_page|;
} # end of else
}
## if action is link display selected page
if ($FORM{'action'} eq "link") {
@field=&get_sku($FORM{'sku'});
print qq| $top_page |;
if ($field[9] ne "") {$photo=qq| |;}
print qq|$photo $font $field[1] $field[2]
$field[4]
\$$field[6]
Código\#: $field[0]
Ver su Pedido
$bottom_page |;
}
## if action is add_to_cart get that taken care of
if ($FORM{'action'} eq "add_to_cart") {
@field=&get_sku($FORM{'sku'});
$z=20;
for($a=0;$a<$option_types;$a++) {
$option[$a]=$FORM{$field[$z]};
$z++;
$high=$option_number*2;
for($x=0;$x<$high;$x=$x+2){
if ($field[$z] eq $option[$a]) {$field[6]=$field[6]+$field[$z+1];}
$z=$z+2;
}
}
open(IN,"$customer_file");
($customer)=;
chomp($customer);
$line="$customer$field[0]~$field[1] $field[2]";
for($a=0;$a<$option_types;$a++) {if ($option[$a]) {$line.=", $option[$a]";}}
$line.="~$field[6]~$FORM{'quantity'}~$field[7]~";
for($a=0;$a<$option_types;$a++) {$line.="~$option[$a]";}
$line.="%%";
close(IN);
open(OUT,">$customer_file");
print OUT $line;
close(OUT);
@summary=&get_summary($FORM{'uid'});
print qq | $top_page $title_front Pedido $title_back a
continuación mostramos un detalle de su pedido.
$summary[0]$font Total: | $font \$$summary[1] |
$bottom_page |;
}
## if action is clear cart then do it
if ($FORM{'action'} eq "clear_cart") {
open(OUT,">$customer_file");
print OUT "";
close(OUT);
print qq| $top_page $title_front Pedido Vaciado $title_back Su
pedido ha sido Vaciado. Continuar
Comprando. $bottom_page |; }
## view the cart
if ($FORM{'action'} eq "view_cart") {
@summary=&get_summary($FORM{'uid'});
if ($summary[2]==1) {
print qq| $top_page $title_front Su Pedido Esta Vacío
$title_back Actualmente Su Pedido no contiene ningún item.
Continuar Comprando.
$bottom_page |;
} else {
print qq | $top_page $title_front Tienda en Línea $title_back A
continuación hay un resumen del contenido de su pedido.
$summary[0]$font Total: | $font \$$summary[1] |
$bottom_page |;
}
}
##########################################################
## Check Out
if ($FORM{'action'} eq "check_out") {
open(IN,"$shipping_file");
(@file=);
close(IN);
@field=split(/\|/,$file[0]);
open(IN,"$tax_file");
@tax_states=;
close(IN);
foreach $state (@tax_states) {
chomp($state);
$d++;
if ($state ne "" && $d != 1) {$select_state=1;}
}
if ($select_state == 1 || $field[0] eq "") {
print qq | $top_page $title_front Check Out Info $title_back
$bottom_page |;
} else {
$FORM{'action'}="finalize";
$shipping=$field[0];
}
}
##########################################################
## Finalize an Order
if ($FORM{'action'} eq "finalize") {
&get_final;
$order=qq|$summary[0]
$font Subtotal: | $font \$$summary[1] |
|;
$order.= qq| $font $shipping_pre $FORM{'shipping_option'}: | $font \$$shipping |
|;
if ($tax != 0) {$order.=qq|$font Sales Tax: | $font \$$tax |
|;}
$order.=qq|$font Total: | $font \$$total |
|;
print qq | $top_page $title_front Confirmación Final $title_back
A continuación mostramos un sumario final de su orden incluyendo gastos
de envío (si son aplicables) e impuestos.
$order
Para formalizar su pedido, por favor llene el siguiente formato y envíelo.|;
if ($PayPal eq "No") {
print qq|