Add Credit Card Info to Database
These are the steps to add credit card info to the database, assuming you are not using a credit card processor. This is not recommended by me or by Cartweaver, and you should use SSL and encrypt the data in the database as well, but these are the basic steps:
First, add five fields to the database:
ALTER TABLE `tbl_orders`
ADD COLUMN order_name varchar(255) null,
ADD COLUMN order_credit varchar(20) null,
ADD COLUMN order_exp varchar(12) null,
ADD COLUMN order_cardtype varchar(20) null,
ADD COLUMN order_ccv varchar(4) null;
Next, add the fields to the insert query on the CWIncProcessOrder.php file. You need to simply add these 5 fields to the end of the $query_rsCWAddOrder query (NOTE: this is the shipping version of the query. If you modified it, you need only add the changes):
WAS:
$query_rsCWAddOrder = sprintf("INSERT INTO tbl_orders
(order_ID, order_CustomerID,
order_Tax, order_Shipping,
order_Total, order_Status,
order_ShipMeth_ID, order_Address1,
order_Address2, order_City,
order_Zip, order_Country,
order_State, order_TransactionID,
order_Date, order_ShipName, order_name, order_credit, order_exp)
VALUES ('%s','%s',%s,%s,%s,'%s',%s,'%s','%s','%s','%s','%s','%s','%s',now(),'%s')",
$thisOrderID
, $_SESSION["customerID"]
, $_SESSION["taxAmt"]
, $_SESSION["shipTotal"]
, $_SESSION["orderTotal"]
, $orderStatusID
, $_SESSION["shipPref"]
, $row_rsCWGetCustShipping["cst_ShpAddress1"]
, $row_rsCWGetCustShipping["cst_ShpAddress2"]
, $row_rsCWGetCustShipping["cst_ShpCity"]
, $row_rsCWGetCustShipping["cst_ShpZip"]
, $row_rsCWGetCustShipping["country_Code"]
, $row_rsCWGetCustShipping["stprv_Code"]
, $transactionID
, $row_rsCWGetCustShipping["cst_ShpName"]);
NEW:
$query_rsCWAddOrder = sprintf("INSERT INTO tbl_orders
(order_ID, order_CustomerID,
order_Tax, order_Shipping,
order_Total, order_Status,
order_ShipMeth_ID, order_Address1,
order_Address2, order_City,
order_Zip, order_Country,
order_State, order_TransactionID,
order_Date, order_ShipName, order_name, order_credit, order_exp, order_cardtype, order_ccv)
VALUES ('%s','%s',%s,%s,%s,'%s',%s,'%s','%s','%s','%s','%s','%s','%s',now(),'%s', '%s', '%s', '%s','%s','%s')",
$thisOrderID
, $_SESSION["customerID"]
, $_SESSION["taxAmt"]
, $_SESSION["shipTotal"]
, $_SESSION["orderTotal"]
, $orderStatusID
, $_SESSION["shipPref"]
, $row_rsCWGetCustShipping["cst_ShpAddress1"]
, $row_rsCWGetCustShipping["cst_ShpAddress2"]
, $row_rsCWGetCustShipping["cst_ShpCity"]
, $row_rsCWGetCustShipping["cst_ShpZip"]
, $row_rsCWGetCustShipping["country_Code"]
, $row_rsCWGetCustShipping["stprv_Code"]
, $transactionID
, $row_rsCWGetCustShipping["cst_ShpName"]
, $_POST["cstCCardHolderName"]
, $_POST["cstCCNumber"]
, $ccExprDate
, $_POST["cstCCardType"]
, $_POST["cstCCV"]);
Next, you will have to add a dummy CC processor so that the credit card form will pop up. Add this code to a file called dummy.php in the ProcessPayment folder:
<?php
$transactionResult = "Approved";
$orderStatusID = 2;
$transactionID = "new";
$transactionMessage = "New transaction";
?>
Then in application.php, set up the payment processor like this:
$cwGlobalSettings->paymentAuthType = "gateway";
$cwGlobalSettings->paymentAuthName = "dummy.php";
This way, the credit card form will be displayed even with no credit card processor.
Then, to add the info to the admin, on the OrderDetails page, add the 5 fields to the display query $query_rsCWOrder:
WAS
<snip>
s.SKU_ID,
s.SKU_MerchSKUID
FROM
</snip>
NEW
<snip>
s.SKU_ID,
s.SKU_MerchSKUID,
o.order_name,
o.order_credit,
o.order_exp,
o.order_cardtype,
o.order_ccv
FROM
</snip>
Next, add the fields (maybe right after the shipping method:)
<tr>
<th align="right">Shipping Method: </th>
<td><?php echo($row_rsCWOrder["shipmeth_Name"]);?></td>
</tr>
<tr>
<th align="right">Credit Card Name: </th>
<td><input name="order_name" value="<?php echo($row_rsCWOrder["order_name"]);?>"></td>
</tr>
<tr>
<th align="right">Credit Card Number: </th>
<td><input name="order_credit" value="<?php echo($row_rsCWOrder["order_credit"]);?>"></td>
</tr>
<tr>
<th align="right">Expiration Date: </th>
<td><input name="order_exp" value="<?php echo($row_rsCWOrder["order_exp"]);?>"></td>
</tr>
<tr>
<th align="right">Card Type: </th>
<td><input name="order_cardtype" value="<?php echo($row_rsCWOrder["order_cardtype"]);?>"></td>
</tr>
<tr>
<th align="right">CCV Code: </th>
<td><input name="order_ccv" value="<?php echo($row_rsCWOrder["order_ccv"]);?>"></td>
</tr>
Then set the update query to automatically update these 5 fields:
$query_rsCW = sprintf("UPDATE tbl_orders
SET order_Status='%s'
, order_ActualShipCharge = %s
, order_ShipDate='%s'
, order_ShipTrackingID='%s',
order_Notes = '%s'
, order_name = '%s'
, order_credit = '%s'
, order_exp = '%s'
, order_cardtype = '%s'
, order_ccv = '%s'
WHERE order_ID='%s'"
,$_POST["order_Status"]
,$_POST["order_ActualShipCharge"]
,mySQLDate($_POST["order_ShipDate"],true)
,$_POST["order_ShipTrackingID"]
,$_POST["order_Notes"]
,$_POST["order_name"]
,$_POST["order_credit"]
,$_POST["order_exp"]
,$_POST["order_cardtype"]
,$_POST["order_ccv"]
,$_POST["orderID"]);