コード例 #1
0
 function m_saveOrderData()
 {
     $comFunc = new c_commonFunctions();
     $comFunc->obDb = $this->obDb;
     $timestamp = time();
     $obPayGateway = new c_paymentGateways();
     # This condition due order not complete by protx
     if (count($_SESSION) == 0) {
         $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
         $this->libFunc->m_mosRedirect($retUrl);
     }
     //	$this->invoice=
     #INTAILIZING
     $this->payMethod = $this->libFunc->ifSet($_SESSION, 'payMethod', ' ');
     $this->grandTotal = $this->libFunc->ifSet($_SESSION, 'grandTotal', ' ');
     $_SESSION['ship_state_id'] = $this->libFunc->ifSet($_SESSION, 'ship_state_id', ' ');
     $_SESSION['bill_state_id'] = $this->libFunc->ifSet($_SESSION, 'bill_state_id', ' ');
     $_SESSION['bill_state'] = $this->libFunc->ifSet($_SESSION, 'bill_state', ' ');
     $_SESSION['ship_state'] = $this->libFunc->ifSet($_SESSION, 'ship_state', ' ');
     $_SESSION['VAT'] = $this->libFunc->ifSet($_SESSION, 'VAT', ' ');
     $_SESSION['comments'] = $this->libFunc->ifSet($_SESSION, 'comments', ' ');
     $_SESSION['giftCertPrice'] = $this->libFunc->ifSet($_SESSION, 'giftCertPrice', '0');
     $_SESSION['giftCertCode'] = $this->libFunc->ifSet($_SESSION, 'giftCertCode', ' ');
     $_SESSION['discountPrice'] = $this->libFunc->ifSet($_SESSION, 'discountPrice', '0');
     $_SESSION['discountCode'] = $this->libFunc->ifSet($_SESSION, 'discountCode', ' ');
     $_SESSION['memberPointsEarned'] = $this->libFunc->ifSet($_SESSION, 'memberPointsEarned', '0');
     $_SESSION['promotionDiscountPrice'] = $this->libFunc->ifSet($_SESSION, 'promotionDiscountPrice', '0');
     if ($_SESSION['useMemberPoints'] == 'yes') {
         $_SESSION['usedMemberPoints'] = $this->libFunc->ifSet($_SESSION, 'usedMemberPoints', '0');
         $_SESSION['memberPointsUsedAmount'] = $this->libFunc->ifSet($_SESSION, 'memberPointsUsedAmount', '0');
     } else {
         $_SESSION['usedMemberPoints'] = 0;
         $_SESSION['memberPointsUsedAmount'] = 0;
     }
     $_SESSION['cartWeight'] = $this->libFunc->ifSet($_SESSION, 'cartWeight', '0');
     $_SESSION['cartWeightPrice'] = $this->libFunc->ifSet($_SESSION, 'cartWeightPrice', '0');
     $_SESSION['alt_ship'] = $this->libFunc->ifSet($_SESSION, "alt_ship", 0);
     $_COOKIE['sourceid'] = $this->libFunc->ifSet($_COOKIE, "sourceid", "");
     if (isset($_SESSION['userid']) && empty($_SESSION['userid'])) {
         unset($_SESSION['userid']);
     }
     if (!isset($_SESSION['userid'])) {
         if (isset($_SESSION['txtpassword'])) {
             $uniqID = $_SESSION['txtpassword'];
         } else {
             $uniqID = uniqid(3);
         }
         #ADDING NOT REGISTERED CUSTOMER
         $this->obDb->query = "select iCustmerid_PK,iRegistered FROM " . CUSTOMERS . " WHERE vEmail = '" . $_SESSION['email'] . "'";
         $qryResult = $this->obDb->fetchQuery();
         $rCount = $this->obDb->record_count;
         if ($rCount > 0 and $qryResult[0]->iRegistered == '0') {
             $this->obDb->query = "UPDATE " . CUSTOMERS . " SET \n\t\t\t\tvFirstName\t\t='" . $this->libFunc->m_addToDB($_SESSION['first_name']) . "',\n\t\t\t\tvLastName\t\t='" . $this->libFunc->m_addToDB($_SESSION['last_name']) . "',\n\t\t\t\tvPassword\t\t= PASSWORD('" . $uniqID . "'),\n\t\t\t\tvAddress1\t\t='" . $this->libFunc->m_addToDB($_SESSION['address1']) . "',\n\t\t\t\tvAddress2\t\t='" . $this->libFunc->m_addToDB($_SESSION['address2']) . "',\n\t\t\t\tvCity\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['city']) . "',\n\t\t\t\tvState\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['bill_state_id']) . "',\n\t\t\t\tvStateName\t='" . $this->libFunc->m_addToDB($_SESSION['bill_state']) . "',\n\t\t\t\tvCountry\t\t='" . $this->libFunc->m_addToDB($_SESSION['bill_country_id']) . "',\n\t\t\t\tvZip\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['zip']) . "',\n\t\t\t\tvCompany\t\t='" . $this->libFunc->m_addToDB($_SESSION['company']) . "',\n\t\t\t\tvPhone\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['phone']) . "',\n\t\t\t\tiMailList\t\t\t='" . $_SESSION['mail_list'] . "',\n\t\t\t\ttmSignupDate\t='" . $timestamp . "',\n\t\t\t\tfMemberPoints ='0',";
             if (isset($_SESSION['txtpassword']) && !empty($_SESSION['txtpassword'])) {
                 $this->obDb->query = $this->obDb->query . "iRegistered ='1',";
             } else {
                 $this->obDb->query = $this->obDb->query . " iRegistered ='0',";
             }
             $this->obDb->query = $this->obDb->query . "vHomePage='" . $this->libFunc->m_addToDB($_SESSION['homepage']) . "' WHERE vEmail='" . $this->libFunc->m_addToDB($_SESSION['email']) . "' AND iRegistered ='0'";
             //die($this->obDb->query);
         } elseif (isset($qryResult[0]->iRegistered) && $qryResult[0]->iRegistered == '1') {
             $_SESSION['cardsave_error'] = 'Email address already in use. Please login to continue with this email address.<br>';
             $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
             header("Location: " . $retUrl);
             $this->libFunc->m_mosRedirect($retUrl);
             die('Please login to continue');
         } else {
             $this->obDb->query = "INSERT INTO " . CUSTOMERS . " SET \n\t\t\t\tvFirstName\t\t='" . $this->libFunc->m_addToDB($_SESSION['first_name']) . "',\n\t\t\t\tvLastName\t\t='" . $this->libFunc->m_addToDB($_SESSION['last_name']) . "',\n\t\t\t\tvEmail\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['email']) . "',\n\t\t\t\tvPassword\t\t= PASSWORD('" . $uniqID . "'),\n\t\t\t\tvAddress1\t\t='" . $this->libFunc->m_addToDB($_SESSION['address1']) . "',\n\t\t\t\tvAddress2\t\t='" . $this->libFunc->m_addToDB($_SESSION['address2']) . "',\n\t\t\t\tvCity\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['city']) . "',\n\t\t\t\tvState\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['bill_state_id']) . "',\n\t\t\t\tvStateName\t='" . $this->libFunc->m_addToDB($_SESSION['bill_state']) . "',\n\t\t\t\tvCountry\t\t='" . $this->libFunc->m_addToDB($_SESSION['bill_country_id']) . "',\n\t\t\t\tvZip\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['zip']) . "',\n\t\t\t\tvCompany\t\t='" . $this->libFunc->m_addToDB($_SESSION['company']) . "',\n\t\t\t\tvPhone\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['phone']) . "',\n\t\t\t\tiMailList\t\t\t='" . $_SESSION['mail_list'] . "',\n\t\t\t\ttmSignupDate\t='" . $timestamp . "',\n\t\t\t\tfMemberPoints ='0',\n\t\t\t\tiStatus ='1',\n\t\t\t\tvHomePage\t\t='" . $this->libFunc->m_addToDB($_SESSION['homepage']) . "'";
             if (isset($_SESSION['txtpassword']) && !empty($_SESSION['txtpassword'])) {
                 $this->obDb->query = $this->obDb->query . ",iRegistered ='1'";
             } else {
                 $this->obDb->query = $this->obDb->query . ",iRegistered ='0'";
             }
         }
         $this->obDb->updateQuery();
         $_SESSION['userid'] = $this->obDb->last_insert_id;
         //Guest checkout broke this stuff. Removed below line as the new solution is to create a inaccessible account rather than not add anything at all. Obviously the customer isnt creating a account and should be able to still do so.
         //$comFunc->m_sendDetails($_SESSION['email']);
         #SETTING SESSION ID
     }
     //die("fail");
     if ($_SESSION['username'] != "" && $_SESSION['mail_list'] != "") {
         $this->obDb->query = "UPDATE " . CUSTOMERS . " SET iMailList=" . $_SESSION['mail_list'] . " WHERE vEmail='" . $_SESSION['email'] . "'";
         $this->obDb->updateQuery();
     }
     if (isset($_SESSION['withoutlogin']) && $_SESSION['withoutlogin'] == 1) {
         $_SESSION['userid'] = 0;
     }
     #UPDATING GIFTCERTIFICATES IF THEY ARE USED
     if ($_SESSION['giftCertPrice'] > 0) {
         $this->obDb->query = "UPDATE " . GIFTCERTIFICATES . " SET fRemaining=fRemaining-" . $_SESSION['giftCertPrice'] . " WHERE vGiftcode='" . $_SESSION['giftCertCode'] . "'";
         $this->obDb->updateQuery();
     }
     #DB QUERY
     $this->obDb->query = "SELECT MAX(iInvoice) as maxInvoice FROM  " . ORDERS;
     $rsInvoice = $this->obDb->fetchQuery();
     $this->invoice = $rsInvoice[0]->maxInvoice;
     if (empty($this->invoice)) {
         $this->invoice = CONST_INVOICE;
     } else {
         $this->invoice++;
     }
     if (isset($_SESSION['freeShip']) && $_SESSION['freeShip'] == 1) {
         $_SESSION['postagePrice'] = 0;
         $_SESSION['postageMethod'] = LBL_FREEPP;
     }
     $time = time();
     if (SELECTED_PAYMENTGATEWAY === 'protx') {
         $protx_apply_avs_cv2 = PROTX_APPLY_AVS_CV2;
         $protx_3d_secure_status = PROTX_3D_SECURE_STATUS;
     } else {
         $protx_apply_avs_cv2 = 0;
         $protx_3d_secure_status = 0;
     }
     $this->VendorTxCode = uniqid(rand(), true);
     #QUERY TO INSERT ORDER DETAILS TO MAIN TABLE
     $this->obDb->query = "INSERT INTO " . ORDERS . " SET \n\t\tiInvoice\t\t\t\t='" . $this->invoice . "',\n\t\tiCustomerid_FK\t='" . $_SESSION['userid'] . "',\n\t\ttmOrderDate\t\t='{$time}',\n\t\tvPayMethod\t\t='" . $this->libFunc->m_addToDB($_SESSION['payMethod']) . "',\n\t\tvShipDescription\t='" . $this->libFunc->m_addToDB($_SESSION['postageMethod']) . "',\n\t\tvShipMethod_Id\t='" . $this->libFunc->m_addToDB($_SESSION['postageId']) . "',\n\t\tfShipTotal\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['postagePrice']) . "',\n\t\tvFirstName\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['first_name']) . "',\n\t\tvLastName\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['last_name']) . "',\n\t\tvEmail\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['email']) . "',\n\t\tvAddress1\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['address1']) . "',\n\t\tvAddress2\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['address2']) . "',\n\t\tvCity\t\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['city']) . "',\n\t\tvState\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['bill_state_id']) . "',\n\t\tvStateName\t\t='" . $this->libFunc->m_addToDB($_SESSION['bill_state']) . "',\n\t\tvCountry\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['bill_country_id']) . "',\n\t\tvZip\t\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['zip']) . "',\n\t\tvCompany\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['company']) . "',\n\t\tvPhone\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['phone']) . "',\n\t\tiSameAsBilling \t\t='" . $this->libFunc->m_addToDB($_SESSION['alt_ship']) . "',\n\t\tvAltCompany\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['alt_company']) . "',\n\t\tvAltName\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['alt_name']) . "',\n\t\tvAltAddress1\t\t='" . $this->libFunc->m_addToDB($_SESSION['alt_address1']) . "',\n\t\tvAltAddress2\t\t='" . $this->libFunc->m_addToDB($_SESSION['alt_address2']) . "',\n\t\tvAltCity\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['alt_city']) . "',\n\t\tvAltState\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['ship_state_id']) . "',\n\t\tvAltStateName\t \t='" . $this->libFunc->m_addToDB($_SESSION['ship_state']) . "',\n\t\tvAltZip\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['alt_zip']) . "',\n\t\tvAltPhone\t \t\t='" . $this->libFunc->m_addToDB($_SESSION['alt_phone']) . "',\n\t\tvAltCountry\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['ship_country_id']) . "',\n\t\tvHomePage\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['homepage']) . "',\n\t\tvDiscountCode\t \t='" . $this->libFunc->m_addToDB($_SESSION['discountCode']) . "',\t\n\t\tfDiscount \t\t\t='" . $this->libFunc->m_addToDB($_SESSION['discountPrice']) . "',\t\n\t\tiGiftcert_FK \t\t='" . $this->libFunc->m_addToDB($_SESSION['giftCertCode']) . "',\t\n\t\tfGiftcertTotal\t\t='" . $this->libFunc->m_addToDB($_SESSION['giftCertPrice']) . "',\t\n\t\tfPromoValue \t\t='" . $this->libFunc->m_addToDB($_SESSION['promotionDiscountPrice']) . "',\n\t\tfTaxRate\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['VAT']) . "',\t\n\t\tfTaxPrice\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['vatTotal']) . "',\t\n\t\ttComments\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['comments']) . "',\t\n\t\tvCustomerIP\t\t\t='" . $_SERVER['REMOTE_ADDR'] . "',\n\t\tfShipByWeightPrice='" . $_SESSION['cartWeightPrice'] . "',\t\n\t\tfShipByWeightKg\t='" . $_SESSION['cartWeight'] . "',\t\n\t\tfCodCharge  \t\t='" . $_SESSION['codPrice'] . "',\t\n\t\tfMemberPoints\t\t='" . $_SESSION['memberPointsUsedAmount'] . "',\t\n\t\tvSid \t\t\t\t\t='" . $_COOKIE['sourceid'] . "',\n\t\tiPayStatus  \t\t='0',\t\n\t\tfTotalPrice  \t\t='" . $this->libFunc->m_addToDB($_SESSION['grandTotal']) . "',\n\t\tiTransactionId\t\t='" . $this->VendorTxCode . "',\n\t\tvRemote_address  \t='',\n\t\tvProtx_apply_avs_cv2  \t='" . $protx_apply_avs_cv2 . "',\n\t\tvProtx_3d_secure_status  \t='" . $protx_3d_secure_status . "',\n\t\tiEarnedPoints ='" . $this->libFunc->m_addToDB(ceil($_SESSION['memberPointsEarned'])) . "'";
     $this->obDb->updateQuery();
     #ORDER ID
     $this->orderId = $this->obDb->last_insert_id;
     $_SESSION['order_id'] = $this->orderId;
     $_SESSION['invoicenumber'] = $this->invoice;
     if ($this->request['IssueNumber'] == '0') {
         $this->request['IssueNumber'] = "";
     }
     if ($this->request['cc_type'] === 'SOLO' && $this->request['cc_type'] === 'SWITCH') {
         $this->request['cc_type'] = 'MAESTRO';
     }
     if (($_SESSION['payMethod'] == 'cc' || $_SESSION['payMethod'] == 'eft') && SELECTED_PAYMENTGATEWAY != 'protx') {
         #INSERTING CREDIT CARD DETAILS
         $this->obDb->query = "INSERT INTO " . CREDITCARDS . " SET \n\t\t\tiOrderid_FK\t\t\t='" . $this->orderId . "',\n\t\t\tvCCnumber\t \t\t='" . $this->libFunc->m_addToDB($_SESSION['cc_number']) . "',\n\t\t\tvCCtype \t\t\t='" . $this->libFunc->m_addToDB($_SESSION['cc_type']) . "',\n\t\t\tvCCyear \t\t\t='" . $this->libFunc->m_addToDB($_SESSION['cc_year']) . "',\n\t\t\tvCCmonth \t\t\t='" . $this->libFunc->m_addToDB($_SESSION['cc_month']) . "',\n\t\t\tvCCstart_year \t='" . $this->libFunc->m_addToDB($_SESSION['cc_start_year']) . "',\n\t\t\tvCCstart_month \t='" . $this->libFunc->m_addToDB($_SESSION['cc_start_month']) . "',\n\t\t\tvAba \t\t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['aba']) . "',\n\t\t\tvAcct \t\t\t\t='" . $this->libFunc->m_addToDB($_SESSION['acct']) . "',\n\t\t\tvCCissuenumber \t='" . $this->libFunc->m_addToDB($_SESSION['issuenumber']) . "'";
         $this->obDb->updateQuery();
     }
     #QUERY TO INSERT PRODUCT DETAILS
     #GETTING DATA FROM SESSION (TEMPORARY DATA)
     $this->obDb->query = "SELECT vTitle,vSeoTitle,fPrice,fRetailPrice,iVendorid_FK,vSku,iQty,iTmpCartId_PK,iProdId_FK,vShipCode,iKit,iGiftWrap,tShortDescription,iTaxable,fVolDiscount,vDownloadablefile,iFreeShip,vShipNotes FROM " . TEMPCART . " T," . PRODUCTS . " P WHERE iProdId_FK=iProdId_PK AND  vSessionId='" . SESSIONID . "'";
     #FLAG TO INDICATE SEPERATE BACKORDER AND NORMAL ORDER
     $_SESSION['backOrderSeperate'] = $this->libFunc->ifSet($_SESSION, 'backOrderSeperate', '0');
     #FLAG TO INDICATE WHETHER PROCESSING BACKORDER OR NOT
     $_SESSION['backOrderProcess'] = $this->libFunc->ifSet($_SESSION, 'backOrderProcess', '0');
     if ($_SESSION['backOrderSeperate'] == 1 && $_SESSION['backOrderProcess'] == 1) {
         $this->obDb->query .= " AND T.iBackOrder='1'";
     } elseif ($_SESSION['backOrderSeperate'] == 1) {
         $this->obDb->query .= " AND T.iBackOrder<>'1'";
     }
     $rowCart = $this->obDb->fetchQuery();
     $rsCount = $this->obDb->record_count;
     if ($rsCount > 0) {
         for ($i = 0; $i < $rsCount; $i++) {
             #FOR LOOP PRODUCT BEGIN
             #MARGIN CALCULATOR
             switch (MARGINSTATUS) {
                 case "increase":
                     $rowCart[$i]->fPrice = $rowCart[$i]->fPrice * MARGINPERCENT / 100 + $rowCart[$i]->fPrice;
                     break;
                 case "decrease":
                     $rowCart[$i]->fPrice = $rowCart[$i]->fPrice - $rowCart[$i]->fPrice * MARGINPERCENT / 100;
                     break;
                 default:
                     $rowCart[$i]->fPrice = $rowCart[$i]->fPrice;
                     break;
             }
             #END MARGIN CALCULATOR
             //--- Switch to retail price if Retail customer
             if ($comFunc->m_checkCustomerType() == 1 && ENABLE_WHOLESALE == 1 && $rowCart[$i]->fRetailPrice > 0) {
                 $rowCart[$i]->fPrice = $rowCart[$i]->fRetailPrice;
             }
             //----End switch price
             //$this->obDb->query ="SELECT vSeoTitle FROM ".PRODUCTS." WHERE iProdId_FK=iProdid_PK ='".$rowCart[$i]->iProdId_FK."'";
             //$SeoReturn=$this->obDb->fetchQuery();
             $qty = $rowCart[$i]->iQty;
             #INSERTING PRODUCTS TO ORDERED PRODUCT TABLE
             $this->obDb->query = "INSERT INTO " . ORDERPRODUCTS . " SET ";
             $this->obDb->query .= "iOrderid_FK\t\t='" . $this->orderId . "',";
             $this->obDb->query .= "iProductid_FK\t='" . $rowCart[$i]->iProdId_FK . "',";
             $this->obDb->query .= "iVendorid_FK\t='" . $rowCart[$i]->iVendorid_FK . "',";
             $this->obDb->query .= "iQty\t\t\t\t='" . $rowCart[$i]->iQty . "',";
             $this->obDb->query .= "iGiftwrapFK\t\t='" . $rowCart[$i]->iGiftWrap . "',";
             $this->obDb->query .= "fPrice\t\t\t\t='" . $rowCart[$i]->fPrice . "',";
             $this->obDb->query .= "vTitle\t\t\t\t='" . $this->libFunc->m_addToDB($rowCart[$i]->vTitle) . "',";
             $this->obDb->query .= "seo_title\t\t\t='" . $this->libFunc->m_addToDB($rowCart[$i]->vSeoTitle) . "',";
             $this->obDb->query .= "vSku\t\t\t\t='" . $this->libFunc->m_addToDB($rowCart[$i]->vSku) . "',";
             $this->obDb->query .= "iKit\t\t\t\t\t='" . $rowCart[$i]->iKit . "',";
             $this->obDb->query .= "fDiscount\t\t\t='" . $rowCart[$i]->fVolDiscount . "',";
             $this->obDb->query .= "tShortDescription='" . $this->libFunc->m_addToDB($rowCart[$i]->tShortDescription) . "',";
             $this->obDb->query .= "iTaxable\t\t\t='" . $rowCart[$i]->iTaxable . "',";
             $this->obDb->query .= "iFreeship\t\t\t='" . $rowCart[$i]->iFreeShip . "',";
             $this->obDb->query .= "vPostageNotes\t='" . $this->libFunc->m_addToDB($rowCart[$i]->vShipNotes) . "'";
             $this->obDb->updateQuery();
             $prodOrderId = $this->obDb->last_insert_id;
             if ($rowCart[$i]->iKit == 1) {
                 $this->obDb->query = "SELECT PK.*,P.vTitle,P.vSku FROM " . PRODUCTKITS . " PK," . PRODUCTS . " P WHERE iProdId_FK=iProdId_PK AND   iKitId='" . $rowCart[$i]->iProdId_FK . "'";
                 $rsKits = $this->obDb->fetchQuery();
                 $kitCount = $this->obDb->record_count;
                 #INSERTING KITS*********************************************
                 if ($kitCount > 0) {
                     for ($k = 0; $k < $kitCount; $k++) {
                         $this->obDb->query = "INSERT INTO " . ORDERKITS . " SET \n\t\t\t\t\t\t\tiOrderid_FK \t\t\t\t='" . $this->orderId . "',\n\t\t\t\t\t\t\tiProductid_FK\t\t\t='" . $rsKits[$k]->iProdId_FK . "',\n\t\t\t\t\t\t\tiProductOrderid_FK\t='" . $prodOrderId . "',\n\t\t\t\t\t\t\tiKitid\t \t\t\t\t\t='" . $rsKits[$k]->iKitId . "',\n\t\t\t\t\t\t\tiKitItem_id\t\t\t\t='" . $rsKits[$k]->iKitId_PK . "',\n\t\t\t\t\t\t\tiKitgroup \t\t\t\t='" . $rsKits[$k]->iKitId . "',\n\t\t\t\t\t\t\tiKitItem_title\t\t\t='" . $this->libFunc->m_addToDB($rsKits[$k]->vTitle . " (" . $rsKits[$k]->vSku . ")") . "'";
                         $this->obDb->updateQuery();
                         $this->m_updateOptions($rowCart[$i]->iTmpCartId_PK, $rsKits[$k]->iProdId_FK, $prodOrderId);
                     }
                 }
             } else {
                 $this->m_updateOptions($rowCart[$i]->iTmpCartId_PK, $rowCart[$i]->iProdId_FK, $prodOrderId);
             }
             #INSERTING CHOICES*********************************************
             $this->obDb->query = "SELECT vDescription,vChoiceVal,fPrice,iChoiceid_PK,vType,iQty  FROM " . CHOICES . ", " . TEMPCHOICES . " WHERE iTmpChoiceId_FK=iChoiceid_PK AND iTmpCartId_FK='" . $rowCart[$i]->iTmpCartId_PK . "'";
             $rsChoices = $this->obDb->fetchQuery();
             $rsChoiceCount = $this->obDb->record_count;
             if ($rsChoiceCount > 0) {
                 for ($j = 0; $j < $rsChoiceCount; $j++) {
                     #IF QUANTITY IS SELECTED
                     if ($rsChoices[$j]->iQty == 1) {
                         $rsChoices[$j]->fPrice = $rsChoices[$j]->fPrice * intval($rsChoices[$j]->vChoiceVal);
                     }
                     $this->obDb->query = "INSERT INTO " . ORDERCHOICES . " SET \n\t\t\t\t\t\tiOrderid_FK \t\t\t\t='" . $this->orderId . "',\n\t\t\t\t\t\tiProductid_FK\t\t\t='" . $rowCart[$i]->iProdId_FK . "',\n\t\t\t\t\t\tiProductOrderid_FK\t='" . $prodOrderId . "',\n\t\t\t\t\t\tiChoiceid_FK\t\t\t='" . $rsChoices[$j]->iChoiceid_PK . "',\n\t\t\t\t\t\tvChoiceValue\t\t\t='" . $this->libFunc->m_addToDB($rsChoices[$j]->vChoiceVal) . "',\n\t\t\t\t\t\tvDescription \t\t\t='" . $this->libFunc->m_addToDB($rsChoices[$j]->vDescription) . "',\n\t\t\t\t\t\tfPrice\t\t\t\t\t\t='" . $rsChoices[$j]->fPrice . "',\n\t\t\t\t\t\tvType \t\t\t\t\t='" . $this->libFunc->m_addToDB($rsChoices[$j]->vType) . "'";
                     $this->obDb->updateQuery();
                 }
                 #END FOR CHOICE
             }
             #ENF IF CHOICE
         }
         #FOR LOOP PRODUCT END
         $this->request = array_merge($this->request, $_SESSION);
     }
     #IF END
     //$obPayGateway=new c_paymentGateways();
     $obPayGateway->payStatus = 1;
     $this->payTotal = number_format($this->grandTotal, 2, '.', '');
     //die($this->payMethod);
     if ($this->payTotal > 0) {
         switch ($this->payMethod) {
             #CARDSAVE
             case "cs_redirect":
                 $cardSave = new c_cardSave($this->orderId);
                 $cardSave->obDb = $this->obDb;
                 $cardSave->obTpl = $this->obTpl;
                 $cardSave->request = $this->request;
                 $cardSave->libFunc = $this->libFunc;
                 $cardSave->m_CardSave_Hosted();
                 exit;
                 break;
                 #FORM BASED PAYPAL
             #FORM BASED PAYPAL
             case "paypal":
                 $this->ObTpl = new template();
                 $this->ObTpl->set_file("TPL_PAYPAL_FILE", $this->paypalTemplate);
                 $this->ObTpl->set_var("TPL_VAR_SITEURL", SITE_SAFEURL);
                 $this->ObTpl->set_var("TPL_VAR_SESSIONID", SESSIONID);
                 $this->ObTpl->set_var("TPL_VAR_PAYACTION", PAYPAL_URL);
                 $this->ObTpl->set_var("TPL_VAR_PAYPALID", PAYPAL_ID);
                 $this->ObTpl->set_var("TPL_VAR_PAYCURRENCY", PAYMENT_CURRENCY);
                 $this->ObTpl->set_var("TPL_VAR_ITEMNAME", SITE_NAME);
                 $this->ObTpl->set_var("TPL_VAR_ITEMNUMBER", $this->orderId);
                 $this->ObTpl->set_var("TPL_VAR_INVOICENUMBER", $this->invoice);
                 $this->ObTpl->set_var("TPL_VAR_GRANDTOTAL", $this->payTotal);
                 $this->ObTpl->pparse("return", "TPL_PAYPAL_FILE");
                 exit;
                 break;
             case "secpay":
                 $this->secpaySubmit();
                 exit;
                 break;
             case "securetrading":
                 $this->offSTSubmit();
                 exit;
                 break;
             case "paypaldirect":
                 $this->m_submitPaypalDirect();
                 break;
                 #(BEGIN) SAGEPAY INTERGRATION
             #(BEGIN) SAGEPAY INTERGRATION
             case "sagepayform":
                 $this->m_sagepayHostedSubmit();
                 exit;
                 break;
                 #(END) SAGEPAY INTERGRATION
             #(END) SAGEPAY INTERGRATION
             case "cc":
                 #IMPLEMENTING PAYMENT GATEWAYS
                 $obPayGateway->payMethod = SELECTED_PAYMENTGATEWAY;
                 switch (SELECTED_PAYMENTGATEWAY) {
                     case "Cardsave":
                         $cardSave = new c_cardSave($this->orderId);
                         $cardSave->obDb = $this->obDb;
                         $cardSave->obTpl = $this->obTpl;
                         $cardSave->request = $this->request;
                         $cardSave->libFunc = $this->libFunc;
                         $cardSave->m_CardSave_Direct();
                         exit;
                         break;
                     case "protx":
                         $this->m_sagepaySubmit();
                         exit;
                         break;
                     case "authorizenet":
                         $authnet_values = array("x_login" => AUTHORIZEPAYMENT_LOGIN, "x_version" => "3.1", "x_delim_char" => "|", "x_delim_data" => "TRUE", "x_url" => "FALSE", "x_type" => AUTHORIZEPAYMENT_TYPE, "x_method" => "CC", "x_tran_key" => AUTHORIZEPAYMENT_KEY, "x_relay_response" => "FALSE", "x_invoice_num" => $this->orderId, "x_card_num" => $this->request['CCNumber'], "x_card_code" => $this->request["cv2"], "x_exp_date" => $this->request['CCMonth'] . $this->request['CCYear'], "x_description" => SITE_NAME . " products", "x_amount" => $this->payTotal, "x_first_name" => $this->request["first_name"], "x_last_name" => $this->request["last_name"], "x_Company" => $this->request["company"], "x_address" => $this->request["address1"] . " " . $this->request["address2"], "x_city" => $this->request["city"], "x_state" => $this->m_stateName($this->request["bill_state_id"], $this->request["bill_state"]), "x_country" => $this->m_countryName($this->request['bill_country_id']), "x_zip" => $this->request["zip"], "x_email" => $this->request["email"], "x_phone" => $this->request["phone"], "x_Ship_To_First_Name" => $this->request["alt_name"], "x_Ship_To_Address" => $this->request["alt_address1"], "x_Ship_To_City" => $this->request["alt_city"], "x_Ship_To_State" => $this->m_stateName($this->request["ship_state_id"], ''), "x_Ship_To_Zip" => $this->request["alt_zip"], "x_country" => $this->m_countryName($this->request['ship_country_id']));
                         $fields = "";
                         foreach ($authnet_values as $key => $value) {
                             $fields .= "{$key}=" . urlencode($value) . "&";
                         }
                         $requestBody = rtrim($fields, "&");
                         $result = $obPayGateway->sendHttpRequest($requestBody, AUTHORIZENET_URL);
                         $obPayGateway->fnRetStatus($result);
                         break;
                     case VERISIGN:
                         if (VERISIGN_USER == "") {
                             $verisignUser = VERISIGN_LOGIN;
                         } else {
                             $verisignUser = VERISIGN_USER;
                         }
                         #SETTING SHIP STATENAME
                         $billStateId = $this->libFunc->ifSet($_SESSION, 'bill_state_id', '0');
                         $shipStateId = $this->libFunc->ifSet($_SESSION, 'ship_state_id', '0');
                         $this->request['CCYear'] = substr($this->request['CCYear'], 2);
                         $verisignStr = "USER="******"&";
                         $verisignStr .= "VENDOR=" . VERISIGN_LOGIN . "&";
                         $verisignStr .= "PARTNER=" . VERISIGN_PARTNER . "&";
                         $verisignStr .= "PWD=" . VERISIGN_PASSWORD . "&";
                         $verisignStr .= "TRXTYPE=S&";
                         $verisignStr .= "TENDER=C&";
                         $verisignStr .= "ACCT=" . $this->request['CCNumber'] . "&";
                         $verisignStr .= "EXPDATE=" . $this->request['CCMonth'] . $this->request['CCYear'] . "&";
                         $verisignStr .= "AMT=" . $this->payTotal . "&";
                         $verisignStr .= "PONUM=" . $this->invoice . "&";
                         $verisignStr .= "CUSTREF=" . $_SESSION['userid'] . "&";
                         $verisignStr .= "CVV2=" . $this->request['cv2'] . "&";
                         $verisignStr .= "FIRSTNAME=" . $_SESSION['first_name'] . "&";
                         $verisignStr .= "LASTNAME=" . $_SESSION['last_name'] . "&";
                         $verisignStr .= "EMAIL=" . $_SESSION['email'] . "&";
                         $verisignStr .= "CITY=" . $_SESSION['city'] . "&";
                         $verisignStr .= "ZIP=" . $_SESSION['zip'] . "&";
                         $verisignStr .= "TAXAMT=" . $_SESSION['vatTotal'] . "&";
                         $verisignStr .= "PHONENUM=" . $_SESSION['phone'] . "&";
                         $verisignStr .= "STREET=" . $_SESSION['address1'] . " " . $_SESSION['address2'] . "&";
                         $verisignStr .= "STATE=" . $this->m_stateName($billStateId, $_SESSION['bill_state']) . "&";
                         $verisignStr .= "BILLTOCOUNTRY=" . $this->m_countryName($_SESSION['bill_country_id']) . "&";
                         $verisignStr .= "SHIPTOFIRSTNAME=" . $_SESSION['first_name'] . "&";
                         $verisignStr .= "SHIPTOLASTNAME=" . $_SESSION['last_name'] . "&";
                         $verisignStr .= "SHIPTOSTREET=" . $_SESSION['address1'] . " " . $_SESSION['address2'] . "&";
                         $verisignStr .= "SHIPTOCITY=" . $_SESSION['city'] . "&";
                         $verisignStr .= "SHIPTOSTATE=" . $this->m_stateName($shipStateId, $_SESSION['bill_state']) . "&";
                         $verisignStr .= "SHIPTOZIP=" . $_SESSION['zip'] . "&";
                         $verisignStr .= "SHIPTOCOUNTRY=" . $this->m_countryName($_SESSION['bill_country_id']) . "&";
                         $verisignStr .= "VERBOSITY=MEDIUM";
                         $libPath = SITE_PATH . "payflowpro/linux/";
                         exec("perl " . $libPath . "execute.pl " . VERISIGN_URL . " " . VERISIGN_PORT . " '{$verisignStr}' '{$libPath}'", $varans);
                         //exec("perl ".SITE_PATH."payflowpro/linux/execute.pl ".VERISIGN_URL." ".VERISIGN_PORT." '$verisignStr'",$varans);
                         $arr = explode("&", $varans[0]);
                         $cntArr = count($arr);
                         if ($cntArr > 0) {
                             for ($i = 0; $i < $cntArr; $i++) {
                                 if ($arr[$i] != "" && strstr($arr[$i], '=')) {
                                     list($key, $value) = split("=", $arr[$i], 2);
                                     $resultArray[$key] = $value;
                                 }
                             }
                         }
                         if (!isset($resultArray['RESULT'])) {
                             $obPayGateway->payStatus = 0;
                             $obPayGateway->errMsg = "Payment gateway is not setup properly";
                         } else {
                             if ($resultArray['RESULT'] != 0) {
                                 $obPayGateway->payStatus = 0;
                             }
                             $obPayGateway->errMsg = $resultArray['RESPMSG'];
                             $obPayGateway->transactionId = $resultArray['PNREF'];
                         }
                         break;
                     case "securetrading":
                         $this->securetradingSubmit();
                         break;
                     case "propay":
                         //Propay Gateway Integration:Starts
                         $url = PROPAY_URL;
                         $this->obDb->query = "select max(iInvoice) as iInvoiceId FROM " . ORDERS;
                         $invoice = $this->obDb->fetchQuery();
                         $invoice_id = $invoice[0]->iInvoiceId;
                         if ($_SESSION['alt_address1'] != "") {
                             $address = $_SESSION['alt_address1'];
                         } else {
                             $address = $_SESSION['address1'];
                         }
                         if ($_SESSION['alt_zip'] != "") {
                             $zip_code = $_SESSION['alt_zip'];
                         } else {
                             $zip_code = $_SESSION['zip'];
                         }
                         $exp_year = substr($_SESSION['cc_year'], -2);
                         $grand_total = $_SESSION['grandTotal'] * 100;
                         $post_string = "<?xml version='1.0'?>\n\t\t\t\t\t\t\t<!DOCTYPE Request.dtd>\n\t\t\t\t\t\t\t<XMLRequest>\n\t\t\t\t\t\t\t<certStr>" . PROPAY_CERTSTRING . "</certStr>\n\t\t\t\t\t\t\t<class>partner</class>\n\t\t\t\t\t\t\t\t\t<XMLTrans>\n\t\t\t\t\t\t\t\t\t<transType>04</transType>\n\t\t\t\t\t\t\t\t\t<accountNum>" . PROPAY_ACCNUMBER . "</accountNum>\n\t\t\t\t\t\t\t\t\t<amount>" . $grand_total . "</amount>\n\t\t\t\t\t\t\t\t\t<addr>" . $address . "</addr>\n\t\t\t\t\t\t\t\t\t<zip>" . $zip_code . "</zip>\n\t\t\t\t\t\t\t\t\t<sourceEmail>" . $_SESSION['email'] . "</sourceEmail>\n\t\t\t\t\t\t\t\t\t<ccNum>" . $_SESSION['cc_number'] . "</ccNum>\n\t\t\t\t\t\t\t\t\t<expDate>" . $_SESSION['cc_month'] . "" . $exp_year . "</expDate>";
                         $post_string .= "<AVS>Y</AVS>";
                         $post_string .= "<CVV2>" . $_SESSION['cv2'] . "</CVV2>\t\n\t\t\t\t\t\t\t\t\t<cardholderName>" . $_SESSION['cardholder_name'] . "</cardholderName>\n\t\t\t\t\t\t\t\t\t<invNum>" . $invoice_id . "</invNum>\n\t\t\t\t\t\t\t\t\t</XMLTrans>\t\n\t\t\t\t\t\t\t</XMLRequest>";
                         $xml_response = $obPayGateway->sendHttpRequest($post_string, $url);
                         $xmlparse = $obPayGateway->xml2array($xml_response);
                         $obPayGateway->propay_response($xmlparse);
                         if ($obPayGateway->flag != "SUCCESS") {
                             $_SESSION['pro'] = $obPayGateway->errMsg;
                             $this->errMsg = $obPayGateway->errMsg;
                             $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
                             $this->libFunc->m_mosRedirect($retUrl);
                         } else {
                             $_SESSION['pro'] = "";
                             $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.process&mode=" . $_SESSION['order_id']);
                             $this->libFunc->m_mosRedirect($retUrl);
                         }
                         //Propay Gateway Integration:Ends
                         break;
                 }
                 # END of online paymentgateways
                 break;
         }
         #End of offline switch
     }
     # End of if paymethod
     if ($obPayGateway->payStatus != 1) {
         return $obPayGateway->errMsg;
     }
     if (isset($obPayGateway->transactionId)) {
         $this->obDb->query = "UPDATE " . ORDERS . " SET iPayStatus='1',iTransactionId='" . $obPayGateway->transactionId . "'   WHERE iOrderid_PK = '" . $this->orderId . "'";
         $rs = $this->obDb->updateQuery();
     }
     $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.process&mode=" . $this->orderId);
     $this->libFunc->m_mosRedirect($retUrl);
 }
コード例 #2
0
 function m_eventHandler()
 {
     if (!isset($this->request['action'])) {
         $this->request['action'] = "";
     }
     $action = explode(".", $this->request['action']);
     $member = explode("=", $this->request['action']);
     if (!isset($this->request['mode'])) {
         $this->request['mode'] = "";
     }
     if (!isset($action[1])) {
         $action[1] = "";
     }
     switch ($action[0]) {
         #HANDLING VIEW(FRONTEND-SHOP BUILDER)
         case "ecom":
             $obShopInterface = new c_shopInterface();
             $obShopInterface->obTpl = $this->obTpl;
             $obShopInterface->obDb = $this->obDb;
             $obShopInterface->request = $this->request;
             $obShopInterface->imageUrl = SITE_URL . "images/";
             $obShopInterface->imagePath = SITE_PATH . "images/";
             $obShopDb = new c_shopDb();
             $obShopDb->obTpl = $this->obTpl;
             $obShopDb->obDb = $this->obDb;
             $obShopDb->request = $this->request;
             $obBill = new c_billShipInfo();
             $obBill->obTpl = $this->obTpl;
             $obBill->obDb = $this->obDb;
             $obBill->request = $this->request;
             $obSearch = new c_search();
             $obSearch->obTpl = $this->obTpl;
             $obSearch->obDb = $this->obDb;
             $obSearch->request = $this->request;
             $obBrand = new c_brand();
             $obBrand->obTpl = $this->obTpl;
             $obBrand->obDb = $this->obDb;
             $obBrand->request = $this->request;
             switch ($action[1]) {
                 case "search":
                     $obSearch->searchTemplate = $this->templatePath . "searchPage.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo; <a href='#'>Search Results</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obSearch->m_searchResults());
                     break;
                 case "brand":
                     $obBrand->brandTemplate = $this->templatePath . "brandPage.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo; <a href='#'>Brand Results</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obBrand->m_brandResults());
                     break;
                 case "details":
                     if ($obShopInterface->m_checkMemberPage()) {
                         $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.details&mode=" . $this->request['mode']);
                         $_SESSION['referer'] = $retUrl;
                         $this->libFunc->authenticate();
                         unset($_SESSION['referer']);
                         $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", $obShopInterface->m_topNavigation('department'));
                         $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_showDeptDetails());
                     } else {
                         $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", $obShopInterface->m_topNavigation('department'));
                         $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_showDeptDetails());
                     }
                     break;
                 case "deptattribute":
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", $obShopInterface->m_topNavigation('department'));
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_showDeptAttributeSort());
                     break;
                 case "pdetails":
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", $obShopInterface->m_topNavigation('product'));
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_showProductDetails());
                     break;
                 case "pfinder":
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo; <a href='#'>Product Finder</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_ProductFinder());
                     break;
                 case "cdetails":
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", $obShopInterface->m_topNavigation('content'));
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_showContentDetails());
                     break;
                 case "deletereview":
                     $obShopDb->m_deleteReview();
                     break;
                 case "reviewForm":
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.reviewForm&mode=" . $this->request['mode']);
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->authenticate();
                     unset($_SESSION['referer']);
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", $obShopInterface->m_topNavigation('product'));
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_showProductDetails());
                     break;
                 case "largeImg":
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_dspLargeImg());
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", $obShopInterface->breadcrumb);
                     break;
                 case "reviewAdd":
                     $this->libFunc->authenticate();
                     $obShopDb->m_reviewAdd();
                     break;
                 case "help":
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.help");
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->authenticate();
                     unset($_SESSION['referer']);
                     $obShopDb->m_reviewHelp();
                     break;
                 case "noHelp":
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.noHelp");
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->authenticate();
                     unset($_SESSION['referer']);
                     $obShopDb->m_reviewNoHelp();
                     break;
                 case "addtocart":
                     if (!$obShopDb->m_addTocart()) {
                         $obShopInterface->template = $this->templatePath . "viewcart.tpl.htm";
                         $obShopInterface->m_viewCart();
                         $obShopDb->stockTemplate = $this->templatePath . "stockControl.tpl.htm";
                         $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Stock control</a>");
                         $this->obTpl->set_var("TPL_VAR_BODY", $obShopDb->m_dspStockMessage());
                     }
                     break;
                 case "addmulticart":
                     if (!$obShopDb->m_addToMulticart()) {
                         $obShopInterface->template = $this->templatePath . "viewcart.tpl.htm";
                         $obShopInterface->m_viewCart();
                         $obShopDb->stockTemplate = $this->templatePath . "stockControl.tpl.htm";
                         $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Stock control</a>");
                         $this->obTpl->set_var("TPL_VAR_BODY", $obShopDb->m_dspStockMessage());
                     }
                     break;
                 case "remove":
                     $obShopDb->m_deleteCart();
                     break;
                 case "updateCart":
                     if ($this->request['mode'] == LANG_EMPTYBASKET) {
                         $obShopDb->m_emptyCart();
                     } elseif ($this->request['mode'] == LANG_UPDATEBASKET) {
                         if (!$obShopDb->m_updateCart()) {
                             $obShopDb->stockTemplate = $this->templatePath . "stockControl.tpl.htm";
                             $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Stock control</a>");
                             $this->obTpl->set_var("TPL_VAR_BODY", $obShopDb->m_dspStockMessage());
                         }
                     } else {
                         $obShopDb->templatePath = $this->templatePath;
                         $obShopDb->Interface = $obShopInterface;
                         if (!$obShopDb->m_updateCart('1')) {
                             $obShopDb->stockTemplate = $this->templatePath . "stockControl.tpl.htm";
                             $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Stock control</a>");
                             $this->obTpl->set_var("TPL_VAR_BODY", $obShopDb->m_dspStockMessage());
                         }
                     }
                     break;
                 case "calcShip":
                     if ($this->request['mode'] == "Get Quote") {
                         $_SESSION['calcShip'] = $this->request['mode'];
                     }
                     $obShopInterface->template = $this->templatePath . "viewcart.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " &nbsp;&raquo;&nbsp;<a href='#'>Shopping basket</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_viewCart());
                     break;
                 case "viewcart":
                     $_SESSION['referer'] = SITE_SAFEURL . "ecom/index.php?action=ecom.viewcart";
                     $obShopInterface->template = $this->templatePath . "viewcart.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", " &nbsp;&raquo;&nbsp;<a href='#'>Shopping basket</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_viewCart());
                     break;
                 case "changepostage":
                     if (DEFAULT_POSTAGE_METHOD == 'zones') {
                         $this->comFunc->m_postageZonePrice($_SESSION['cartweight'], $this->request['countryid'], $_SESSION['grandTotal'], 1, $_SESSION['subtotal'], $_SESSION['grandsubTotal'], $_SESSION['VAT']);
                     } elseif (DEFAULT_POSTAGE_METHOD == 'cities') {
                         $this->comFunc->m_postageCityPrice($_SESSION['cartweight'], $this->request['countryid'], $_SESSION['grandTotal'], 1, $_SESSION['subtotal'], $_SESSION['grandsubTotal'], $_SESSION['VAT'], $this->request['stateid']);
                     }
                     break;
                 case "updateviewcart":
                     $this->comFunc->m_UpdateViewCart();
                     break;
                 case "changecountry":
                     $this->comFunc->m_postageCityCountry($this->request['countryid']);
                     break;
                 case "giftwrap":
                     $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"" . $cartUrl . "\">Shopping basket</a>&nbsp;&raquo;&nbsp;<a href='#'>Gift wrap</a>");
                     $obShopInterface->giftTemplate = $this->templatePath . "giftwrap.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_dspGiftWrap());
                     break;
                 case "giftAdd":
                     $obShopDb->m_addGiftWrap();
                     break;
                 case "removeGift":
                     $obShopDb->m_removeGift();
                     break;
                 case "backitem":
                     $obShopDb->m_backOrderSeperate();
                     break;
                 case "backremove":
                     $obShopDb->m_deleteCart();
                     break;
                 case "instructions":
                     $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"" . $cartUrl . "\">Shopping basket</a>&nbsp;&raquo;&nbsp;<a href='#'>Backorder instructions</a>");
                     $obShopInterface->giftTemplate = $this->templatePath . "backorder.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_dspBackOrderInstructions());
                     break;
                 default:
                     $obShopInterface->template = $this->templatePath . "viewcart.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Shopping basket</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obShopInterface->m_viewCart());
                     break;
             }
             break;
         case "checkout":
             $obBill = new c_billShipInfo();
             $obBill->obTpl = $this->obTpl;
             $obBill->obDb = $this->obDb;
             $obBill->request = $this->request;
             $obPayment = new c_payment();
             $obPayment->obTpl = $this->obTpl;
             $obPayment->obDb = $this->obDb;
             $obPayment->request = $this->request;
             $user = new c_userInterface();
             $user->obTpl = $this->obTpl;
             $user->obDb = $this->obDb;
             $user->request = $this->request;
             $obReview = new c_review();
             $obReview->obTpl = $this->obTpl;
             $obReview->obDb = $this->obDb;
             $obReview->request = $this->request;
             $obSaveOrder = new c_saveOrder();
             $obSaveOrder->obTpl = $this->obTpl;
             $obSaveOrder->obDb = $this->obDb;
             $obSaveOrder->request = $this->request;
             $obreceipt = new c_receipt();
             $obreceipt->obTpl = $this->obTpl;
             $obreceipt->obDb = $this->obDb;
             $obreceipt->request = $this->request;
             $this->libFunc = new c_libFunctions();
             $cardSave = new c_cardSave();
             $cardSave->obDb = $this->obDb;
             $cardSave->obTpl = $this->obTpl;
             $cardSave->request = $this->request;
             $cardSave->libFunc = $this->libFunc;
             switch ($action[1]) {
                 case "login":
                     $obBill->m_checkLogin();
                     $obBill->loginTemplate = $this->templatePath . "checkoutLogin.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Login</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obBill->m_checkoutLoginForm());
                     break;
                 case "lost":
                     $user->cart = 1;
                     $user->m_sendPassword();
                     $obBill->loginTemplate = $this->templatePath . "checkoutLogin.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Login</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obBill->m_checkoutLoginForm());
                     break;
                 case "loginForm":
                     $obBill->loginTemplate = $this->templatePath . "checkoutLogin.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Login</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obBill->m_checkoutLoginForm());
                     break;
                 case "logout":
                     session_destroy();
                     $retUrl1 = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
                     $_SESSION['referer'] = $retUrl1;
                     $this->libFunc->authenticate();
                     unset($_SESSION['referer']);
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=checkout.login");
                     header("Location:" . $retUrl);
                     break;
                 case "billing":
                     $this->comFunc->m_checkShoppingCart();
                     $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
                     //$_SESSION['referer']=$retUrl;
                     #IF WITHOUT LOGIN CHECKUT SELECTED
                     //if(!isset($this->request['email']) && empty($this->request['email'])){
                     #IF EMAIL NOT SPECIFIED THEN CHECK LOGIN DETAILS
                     //$this->libFunc->m_cartAuthenticate();
                     //session_unregister('referer');
                     //}
                     $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"" . $cartUrl . "\">Shopping basket</a>&nbsp;&raquo;&nbsp;<a href='#'>Billing &amp; delivery address</a>");
                     unset($_SESSION['referer']);
                     $obBill->billShipTemplate = $this->templatePath . "ConfirmOrderAndBillShip.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BODY", $obBill->m_billShipInfoForm());
                     break;
                 case "billingerr":
                     $this->comFunc->m_checkShoppingCart();
                     $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
                     //$_SESSION['referer']=$retUrl;
                     #IF WITHOUT LOGIN CHECKUT SELECTED
                     //if(!isset($this->request['email']) && empty($this->request['email'])){
                     #IF EMAIL NOT SPECIFIED THEN CHECK LOGIN DETAILS
                     //$this->libFunc->m_cartAuthenticate();
                     //session_unregister('referer');
                     //}
                     $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"" . $cartUrl . "\">Shopping basket</a>&nbsp;&raquo;&nbsp;<a href='#'>Billing &amp; delivery address</a>");
                     unset($_SESSION['referer']);
                     $obBill->billShipTemplate = $this->templatePath . "ConfirmOrderAndBillShip.tpl.htm";
                     $obBill->err = 1;
                     $obBill->errMsg = 'There was a problem with your payment details.';
                     $this->obTpl->set_var("TPL_VAR_BODY", $obBill->m_billShipInfoForm());
                     break;
                 case "addBillShipInfo":
                     $this->comFunc->m_checkShoppingCart();
                     $result = $obBill->m_verifyBillShipAdd();
                     if ($result) {
                         echo "||ERROR||1||" . $result . "||";
                     } else {
                         $obBill->m_saveBillShipInfo();
                     }
                     break;
                 case "shipping":
                     $this->comFunc->m_checkShoppingCart();
                     $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->m_cartAuthenticate();
                     unset($_SESSION['referer']);
                     $obBill->postageTemplate = $this->templatePath . "ConfirmOrderAndBillShip.tpl.htm";
                     $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"" . $cartUrl . "\">Shopping basket</a>&nbsp;&raquo;&nbsp;<a href='#'>Postage information</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obBill->m_postageSelect());
                     break;
                 case "updatePostage":
                     $this->comFunc->m_checkShoppingCart();
                     $obBill->m_updatePostage();
                     break;
                 case "payment":
                     $this->comFunc->m_checkShoppingCart();
                     $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->m_cartAuthenticate();
                     unset($_SESSION['referer']);
                     $obPayment->paymentTemplate = $this->templatePath . "payment.tpl.htm";
                     $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"" . $cartUrl . "\">Shopping basket</a>&nbsp;&raquo;&nbsp;<a href='#'>Choose a payment method</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obPayment->m_paymentMethods());
                     break;
                 case "review":
                     $siteUrl = SITE_URL . "ecom/index.php?action=checkout.billing";
                     $this->libFunc->m_mosRedirect($this->libFunc->m_safeUrl($siteUrl));
                     break;
                 case "reviewit":
                     $this->comFunc->m_checkShoppingCart();
                     $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->m_cartAuthenticate();
                     unset($_SESSION['referer']);
                     if ($obPayment->m_verifyPaymentGateway()) {
                         $obPayment->paymentTemplate = $this->templatePath . "payment.tpl.htm";
                         //$paymentUrl=$this->libFunc->m_safeUrl(SITE_URL."ecom/index.php?action=checkout.payment");
                         $paymentUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=checkout.billing");
                         $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                         $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"" . $cartUrl . "\">Shopping basket</a>&nbsp;&raquo;&nbsp;<a href=\"" . $paymentUrl . "\">Billing & delivery address</a>&nbsp;&raquo;&nbsp;<a href='#'>Review your order</a>");
                         $this->obTpl->set_var("TPL_VAR_BODY", $obPayment->m_paymentMethods());
                     } else {
                         $obReview->libFunc = $this->libFunc;
                         $obReview->reviewTemplate = $this->templatePath . "review.tpl.htm";
                         //$paymentUrl=$this->libFunc->m_safeUrl(SITE_URL."ecom/index.php?action=checkout.payment");
                         $paymentUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=checkout.billing");
                         $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                         $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"" . $cartUrl . "\">Shopping basket</a>&nbsp;&raquo;&nbsp;<a href=\"" . $paymentUrl . "\">Billing & delivery address</a>&nbsp;&raquo;&nbsp;<a href='#'>Review your order</a>");
                         $this->obTpl->set_var("TPL_VAR_BODY", $obReview->m_reviewCheckout());
                     }
                     break;
                 case "saveorder":
                     $obSaveOrder->cardsaveTemplate = $this->templatePath . "cardsave.tpl.htm";
                     $this->comFunc->m_checkShoppingCart();
                     $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->m_cartAuthenticate();
                     unset($_SESSION['referer']);
                     $obSaveOrder->worldpayTemplate = $this->templatePath . "worldpay.tpl.htm";
                     $obSaveOrder->secpayTemplate = $this->templatePath . "secpay.tpl.htm";
                     $obSaveOrder->hsbcTemplate = $this->templatePath . "hsbc.tpl.htm";
                     $obSaveOrder->barclayTemplate = $this->templatePath . "barclay.tpl.htm";
                     $obSaveOrder->paypalTemplate = $this->templatePath . "paypal.tpl.htm";
                     $obSaveOrder->offSTTemplate = $this->templatePath . "offst.tpl.htm";
                     #(BEGIN) SAGEPAY INTEGRATION
                     $obSaveOrder->sagepayTemplate = $this->templatePath . "sageform.tpl.htm";
                     #(END) SAGEPAY INTEGRATION
                     $this->comFunc->m_checkShoppingCart();
                     $obBill->errMsg = $obSaveOrder->m_saveOrderData();
                     //$obSaveOrder->m_saveOrderData();
                     $obBill->billShipTemplate = $this->templatePath . "ConfirmOrderAndBillShip.tpl.htm";
                     $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"" . $cartUrl . "\">Shopping basket</a>&nbsp;&raquo;&nbsp;<a href='#'>Choose a payment method</a>");
                     unset($_SESSION['userid']);
                     unset($_SESSION['username']);
                     $this->obTpl->set_var("TPL_VAR_BODY", $obBill->m_billShipInfoForm());
                     break;
                 case "return":
                     //PAYPAL AND OTHER RETURN PAGE DISPLAY
                     $obreceipt->template = $this->templatePath . "return.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href=\"#\">Order Confirmation</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obreceipt->m_return());
                     break;
                 case "IPN":
                     //PAYPAL INSTANT PAYMENT NOTIFICATION
                     $result = $obreceipt->m_Paypal_IPN_Notification();
                     if ($result[0] == "1") {
                         $obreceipt->m_sendOrderDetails($result[1]);
                     }
                     break;
                 case "sage3d":
                     $obreceipt->m_Sagepay_3D1();
                     break;
                 case "sage3d2":
                     $obreceipt->m_Sagepay_3D2();
                     break;
                 case "sage3dr":
                     $obreceipt->m_Sagepay_3DR();
                     break;
                 case "cs3d":
                     $cardSave->m_cardSave_3D1();
                     break;
                 case "cs3d2":
                     $cardSave->m_cardSave_3D2();
                     break;
                 case "cs3dr":
                     $cardSave->m_cardSave_3DR();
                     break;
                 case "cshcb":
                     $cardSave->m_cardSave_Hosted_Callback("0");
                     break;
                 case "cshcb2":
                     $cardSave->m_cardSave_Hosted_Callback("1");
                     break;
                 case "process":
                     $obreceipt->processTemplate = $this->templatePath . "orderProcessed.tpl.htm";
                     $obPayment->errMsg = $obreceipt->m_sendOrderDetails();
                     break;
                 case "status":
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=checkout.status&mode=" . $this->request['mode']);
                     $_SESSION['referer'] = $retUrl;
                     if ((!isset($_SESSION['userid']) || !isset($_SESSION['username']) || $_SESSION['userid'] == "") && !isset($_SESSION['customer']) && !isset($_SESSION['email'])) {
                         $siteUrl = SITE_URL . "ecom/index.php?action=checkout.loginForm";
                         $this->libFunc->m_mosRedirect($this->libFunc->m_safeUrl($siteUrl));
                     }
                     unset($_SESSION['referer']);
                     $obreceipt->template = $this->templatePath . "orderProcessed.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Order Processed</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obreceipt->m_orderProcessed());
                     break;
                 case "receipt":
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=checkout.receipt&mode=" . $this->request['mode']);
                     $_SESSION['referer'] = $retUrl;
                     if ((!isset($_SESSION['userid']) || !isset($_SESSION['username']) || $_SESSION['userid'] == "") && !isset($_SESSION['customer']) && !isset($_SESSION['email'])) {
                         $siteUrl = SITE_URL . "ecom/index.php?action=checkout.loginForm";
                         $this->libFunc->m_mosRedirect($this->libFunc->m_safeUrl($siteUrl));
                     }
                     //$this->libFunc->m_cartAuthenticate();
                     unset($_SESSION['referer']);
                     $obreceipt->receiptTemplate = $this->templatePath . "receipt.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>View Receipt</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obreceipt->m_dspreceipt());
                     break;
                 case "editOrder":
                     if ((!isset($_SESSION['userid']) || !isset($_SESSION['username']) || $_SESSION['userid'] == "") && !isset($_SESSION['customer']) && !isset($_SESSION['email'])) {
                         $siteUrl = SITE_URL . "ecom/index.php?action=checkout.loginForm";
                         $this->libFunc->m_mosRedirect($this->libFunc->m_safeUrl($siteUrl));
                     }
                     $obShopDb = new c_shopDb();
                     $obShopDb->obTpl = $this->obTpl;
                     $obShopDb->obDb = $this->obDb;
                     $obShopDb->request = $this->request;
                     $obShopDb->m_addInvoiceToCart();
                     $cartUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=ecom.viewcart");
                     $this->libFunc->m_mosRedirect($cartUrl);
                     break;
                 case "cardsave_success":
                     if ($_REQUEST['StatusCode'] != '0') {
                         $_SESSION['Message'] = $_REQUEST['Message'];
                         $retUrl = SITE_URL . "ecom/index.php?action=checkout.billing";
                         $this->libFunc->m_mosRedirect($this->libFunc->m_safeUrl($retUrl));
                         exit;
                     }
                     $vAuthCode = $_SESSION['vAuthCode'] = str_replace("AuthCode: ", "", $_REQUEST['Message']);
                     if ($vAuthCode) {
                         $this->obDb->query = "update " . ORDERS . " set vAuthCode='{$vAuthCode}' where iOrderid_PK=" . $_REQUEST['OrderID'];
                         $this->obDb->updateQuery();
                     }
                     $obCSR->receiptTemplate = $this->templatePath . "cardsave_success.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Cardsave Success</a>");
                     $retUrl = SITE_URL . "ecom/index.php?action=checkout.process&mode=" . $_REQUEST['OrderID'];
                     $this->obDb->query = "update " . ORDERS . " set iOrderStatus=1 where iOrderid_PK=" . $_REQUEST['OrderID'];
                     $this->obDb->updateQuery();
                     $this->libFunc->m_mosRedirect($this->libFunc->m_safeUrl($retUrl));
                     break;
                 case "backorder":
                     $obreceipt->m_processBackorder();
                     break;
                 case "supplierConf":
                     $obreceipt->receiptTemplate = $this->templatePath . "supplier_conf.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Confirmation</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obreceipt->m_supplierOrderConf());
                     break;
                 default:
                     $this->comFunc->m_checkShoppingCart();
                     $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.billing");
                     $_SESSION['referer'] = $retUrl;
                     if (!isset($this->request['email']) && empty($this->request['email'])) {
                         $this->libFunc->m_cartAuthenticate();
                         unset($_SESSION['referer']);
                     } elseif ($obBill->m_valiadateEmail() == 1) {
                         $obBill->loginTemplate = $this->templatePath . "checkoutLogin.tpl.htm";
                         $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Login</a>");
                         $this->obTpl->set_var("TPL_VAR_BODY", $obBill->m_checkoutLoginForm());
                         break;
                     }
                     $obBill->billShipTemplate = $this->templatePath . "ConfirmOrderAndBillShip.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Shopping basket</a>");
                     $this->obTpl->set_var("TPL_VAR_BODY", $obBill->m_billShipInfoForm());
                     break;
             }
             break;
         case "wishlist":
             if (USEWISHLIST != 1) {
                 $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "index.php?action=error&mode=content");
                 header("Location:" . $retUrl);
                 exit;
             }
             $obWishInterface = new c_wishInterface();
             $obWishInterface->obTpl = $this->obTpl;
             $obWishInterface->obDb = $this->obDb;
             $obWishInterface->request = $this->request;
             $obWishlistDb = new c_wishlistDb();
             $obWishlistDb->obTpl = $this->obTpl;
             $obWishlistDb->obDb = $this->obDb;
             $obWishlistDb->request = $this->request;
             $this->libFunc = new c_libFunctions();
             switch ($action[1]) {
                 case "display":
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=wishlist.display");
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->authenticate();
                     unset($_SESSION['referer']);
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>My Wish List</a>");
                     $obWishInterface->template = $this->templatePath . "wishlist.tpl.htm";
                     $obWishInterface->libFunc = $this->libFunc;
                     $this->obTpl->set_var("TPL_VAR_BODY", $obWishInterface->m_showWishlist());
                     break;
                 case "add":
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=wishlist.add&mode=" . $this->request['mode']);
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->authenticate();
                     unset($_SESSION['referer']);
                     $this->libFunc->authenticate();
                     $obWishlistDb->m_insertWishlist();
                     break;
                 case "emailadd":
                     $this->libFunc->authenticate();
                     $obWishlistDb->m_addWishEmail();
                     break;
                 case "emailsend":
                     $this->libFunc->authenticate();
                     $obWishInterface->m_sendEmail();
                     break;
                 case "emailremove":
                     $this->libFunc->authenticate();
                     $obWishlistDb->m_removeWishEmail();
                     break;
                 case "modify":
                     $this->libFunc->authenticate();
                     $obWishlistDb->m_modifyWishlist();
                     break;
                 default:
                     $this->libFunc->authenticate();
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>My wishlist</a>");
                     $obWishInterface->template = $this->templatePath . "wishlist.tpl.htm";
                     $obWishInterface->libFunc = $this->libFunc;
                     $this->obTpl->set_var("TPL_VAR_BODY", $obWishInterface->m_showWishlist());
                     break;
             }
             break;
         case "compare":
             if (USECOMPARE != 1) {
                 $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "index.php");
                 header("Location:" . $retUrl);
                 exit;
             }
             $obCompareInterface = new c_compareInterface();
             $obCompareInterface->obTpl = $this->obTpl;
             $obCompareInterface->obDb = $this->obDb;
             $obCompareInterface->request = $this->request;
             $obCompareDb = new c_comparelistDb();
             $obCompareDb->obTpl = $this->obTpl;
             $obCompareDb->obDb = $this->obDb;
             $obCompareDb->request = $this->request;
             $this->libFunc = new c_libFunctions();
             switch ($action[1]) {
                 case "display":
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=compare.display");
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->authenticate();
                     unset($_SESSION['referer']);
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>My Comparison List</a>");
                     $obCompareInterface->template = $this->templatePath . "comparelist.tpl.htm";
                     $obCompareInterface->libFunc = $this->libFunc;
                     $this->obTpl->set_var("TPL_VAR_BODY", $obCompareInterface->m_showComparelist());
                     break;
                 case "add":
                     $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "ecom/index.php?action=compare.add&mode=" . $this->request['mode']);
                     $_SESSION['referer'] = $retUrl;
                     $this->libFunc->authenticate();
                     unset($_SESSION['referer']);
                     $this->libFunc->authenticate();
                     $obCompareDb->m_insertComparelist();
                     break;
                 case "modify":
                     $this->libFunc->authenticate();
                     $obCompareDb->m_modifyComparelist();
                     break;
                 default:
                     $this->libFunc->authenticate();
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>My Comaparison list</a>");
                     $obCompareInterface->template = $this->templatePath . "comparelist.tpl.htm";
                     $obCompareInterface->libFunc = $this->libFunc;
                     $this->obTpl->set_var("TPL_VAR_BODY", $obCompareInterface->m_showComparelist());
                     break;
             }
             break;
         case "enquiry":
         case "wishlist":
             $obEnquiryInterface = new c_enquiryInterface();
             $obEnquiryInterface->obTpl = $this->obTpl;
             $obEnquiryInterface->obDb = $this->obDb;
             $obEnquiryInterface->request = $this->request;
             $obEnquiryDb = new c_enquiryDb();
             $obEnquiryDb->obTpl = $this->obTpl;
             $obEnquiryDb->obDb = $this->obDb;
             $obEnquiryDb->request = $this->request;
             $this->libFunc = new c_libFunctions();
             switch ($action[1]) {
                 case "dspForm":
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Product Enquiry</a>");
                     $obEnquiryInterface->enquiryTemplate = $this->templatePath . "enquiry.tpl.htm";
                     $obEnquiryInterface->libFunc = $this->libFunc;
                     $this->obTpl->set_var("TPL_VAR_BODY", $obEnquiryInterface->m_showEnquiryForm());
                     break;
                 case "post":
                     $obEnquiryInterface->m_sendEmail();
                     break;
                 case "status":
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Product Enquiry</a>");
                     $obEnquiryInterface->enquiryTemplate = $this->templatePath . "enquirySubmit.tpl.htm";
                     $this->obTpl->set_var("TPL_VAR_BODY", $obEnquiryInterface->m_showStatus());
                     break;
                 default:
                     $this->obTpl->set_var("TPL_VAR_BREDCRUMBS", "&nbsp;&raquo;&nbsp;<a href='#'>Product Enquiry</a>");
                     $obEnquiryInterface->enquiryTemplate = $this->templatePath . "enquiry.tpl.htm";
                     $obEnquiryInterface->libFunc = $this->libFunc;
                     $this->obTpl->set_var("TPL_VAR_BODY", $obEnquiryInterface->m_showEnquiryForm());
                     break;
             }
             break;
         default:
             $retUrl = $this->libFunc->m_safeUrl(SITE_URL . "index.php");
             header("Location:" . $retUrl);
             exit;
             break;
     }
 }