This is helpful and I think I am following. I think I may have simplified it a little to much by only posting a small amount of what is actually on this page. Here is the rest. I think it changes up how I would insert your code a bit. (I tried but it broke the page) Thanks again for the help.
[php]<?php ob_start(); session_start();
require_once(‘siteURL.php’);
require_once(’…/plugins/sqlconnect.php’);
require_once(’…/plugins/functions.php’);
$userName = $_SESSION[‘myusername’];
//Create accepted field array
$accepted = array(‘paymentType’, ‘billingAddress’, ‘shippingAddress’, ‘shipDate’, ‘PO’, ‘salesRep’, ‘repName’, ‘email’, ‘instructions’);
//Add post to session based on accepted field array
foreach ( $_POST as $details=>$field ) {
echo ("$details = $field
");
if ( in_array( $details, $accepted )) {
$_SESSION[$details] = $field;
}
}
//If order is less than 500, return to cart. Bypass if applying coupon code.
if (($_POST[‘orderTotal’] < 500) && ((!isset($_POST[‘couponCodeBtn’])) && (isset($_POST[‘Submit’])))) { header(“Location: …/cart.php?error=Your order must be at least $500 to continue.”);
//If coupon code applied return to cart.
} elseif ((isset($_POST[‘couponCodeBtn’])) && (!isset($_POST[‘Submit’]))) {
//If coupon code empty, unset coupon
if (((empty($_POST[‘couponCode’])) || ($_POST[‘couponCode’] == " "))) {
unset($_SESSION[‘couponCode’]);
header(“Location: …/cart.php?couponCodeMessage=Coupon removed”);
} else {
//Check if coupon code is valid
if (couponValid($_POST[‘orderTotal’], $userName, $_POST[‘couponCode’]) == “true”) {
$_SESSION[‘couponCode’] = $_POST[‘couponCode’];
header(“Location: …/cart.php?couponCodeMessage=Accepted!”);
} else {
header(“Location: …/cart.php?couponCodeError=” . couponValid($_POST[‘orderTotal’], $userName, $_POST[‘couponCode’]) . “”);
}
}
} else {
//Check if coupon minimum met
if (couponMinCheck($_POST['orderTotal'], $_POST['couponCode']) != "true") {
header("Location: ../cart.php?error=Coupon $_POST[couponCode] requires a minimum of $" . couponMinCheck($_POST['orderTotal'], $_POST['couponCode']) . ".&couponCodeError=Minimum $" . couponMinCheck($_POST['orderTotal'], $_POST['couponCode']) . "");
} else {
//If credit card/billing/shipping info need proceed to checkout, ortherwise proceed to confirm
if ((($_SESSION['paymentType'] == "creditCard") && (!isset($_SESSION['cardType']))) || ($_SESSION['billingAddress'] == "billingAddressNew") || ($_SESSION['shippingAddress'] == "shippingAddressNew")) {
header("Location: " . $siteSURL . "cart_checkout.php");
} else {
header("Location: " . $siteSURL . "cart_confirm.php");
}
}
}
?>[/php]