Tom Muck

Alpha Dog Blues Band
Home page
All articles
All Extensions | Extension News | Extension FAQs | Customer Login
Books authored or co-authored by Tom Muck
Extensions, books, and other products | Customer Login
Your current cart contents
Tom-Muck.com Blog | CMXTraneous Blog | Flash Remoting Blog
About the site

Payby Credit Card Or Check

Setting up "Pay by Credit card or check"

This modification can be used for "Pay by Credit Card or Check" or for "Pay now or request a Quote". This is simply a matter of changing the credit card processor from your payment processor that is set up in the application.php file to "none" on the fly, based on user input. You should be able to set up a form field on the order form to allow for checks to be sent on CWIncOrderForm.php:

<p>Pay by:<br />
Send check:
<input type="radio" name="paymenttype" value="0" />
Credit Card:
<input type="radio" name="paymenttype" value="1" />
</p>

then add a bit of code to the CWIncOrderFormSetup.php file:

if(isset($_POST["paymenttype"])) {
$_SESSION["paymenttype"] = $_POST["paymenttype"];
}

then a bit of code to the CWIncShowCartSetup.php file:

if(isset($_SESSION["paymenttype"])) {
  switch($_SESSION["paymenttype"]) {
    case 0:
      $cartweaver->settings->paymentAuthType = "none";
      $cartweaver->settings->paymentAuthName = "none";
      break;
    case 1:
      $cartweaver->settings->paymentAuthType = "gateway";
      $cartweaver->settings->paymentAuthName = "CWIncAuthorizeNet.php";
      break;
  }
}

Also, if you want to change the confirmation emails based on the payment type, add this code to the top of CWIncConfirmation.php as well:

if(isset($_SESSION["paymenttype"])) {
  switch($_SESSION["paymenttype"]) {
    case 0:
      $cartweaver->settings->paymentAuthType = "none";
      $cartweaver->settings->paymentAuthName = "none";
      break;
    case 1:
      $cartweaver->settings->paymentAuthType = "gateway";
      $cartweaver->settings->paymentAuthName = "CWIncAuthorizeNet.php";
      break;
  }
}

Then you can make your changes in the email however you like, such as:

if($cartweaver->settings->paymentAuthType == "none") {
  $emailContents .= "\r\nCustomer has requested to pay by check. OrderID: " . $row_rsCWOrder["order_ID"];
}else {
  $emailContents .= "\r\nOrder ID: " . $row_rsCWOrder["order_ID"];
}

Back to Cartweaver PHP FAQ, code changes, and samples

Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
About | Privacy Policy | Contact | License Agreement | ©2002-2025 Tom Muck | Dreamweaver Extensions