We only have two add to cart buttons on the website and we are only passing a single 'product' but are running into all sorts of problems.
This is one of the add to cart buttons, which is basically for new orders on the site....
<form name="eCartSMC_1_ATC_<?php echo($rsEDITFORM->getColumnVal("SMCformID")); ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".htmlentities($_SERVER["QUERY_STRING"]):""; ?>">
<input type="hidden" name="eCartSMC_1_ID_Add" value="<?php echo($rsEDITFORM->getColumnVal("SMCformID")); ?>">
<button type="submit" class="btn btn-info" name="eCartSMC_1_ATC" id="eCartSMC_1_ATC">Add to Basket <i class="fal fa-shopping-cart"></i></button>
</form>
And this is it's corresponding behaviour on the same page...
<?php
// WA eCart AddToCart
if (isset($_POST["eCartSMC_1_ATC"]) || isset($_POST["eCartSMC_1_ATC_x"])) {
$ATC_itemID = $_POST["eCartSMC_1_ID_Add"];
$ATC_AddIfIn = 4;
$ATC_RedirectAfter = "health-screening-form-checkout.php";
$ATC_RedirectIfIn = "";
$ATC_itemName = "Sports Medical Certificate Form Ref. ".$_SESSION['NEWformID'] ."";// column binding
$ATC_itemDescription = "Order Ref. SMC".$_SESSION['eCartSMC_OrderID'] ."";// column binding
$ATC_itemThumbnail = "";// column binding
$ATC_itemWeight = floatval("0");// column binding
$ATC_itemQuantity = floatval("1");// column binding
$ATC_itemPrice = floatval("65");// column binding
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$eCartSMC->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemThumbnail, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice);
if ($ATC_RedirectAfter != "" && $eCartSMC->redirStr == "") {
$eCartSMC->redirStr = $ATC_RedirectAfter;
}
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
}
else {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];
}
}
}
?>
This is the other, which appears for orders that customers are returning to (that they haven't yet paid for)....
<form name="eCartSMC_1_ATC_<?php echo($rsEDITFORM->getColumnVal("SMCformID")); ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".htmlentities($_SERVER["QUERY_STRING"]):""; ?>">
<input type="hidden" name="eCartSMC_1_ID_Add" value="<?php echo($rsEDITFORM->getColumnVal("SMCformID")); ?>">
<button type="submit" class="btn btn-info float-right" name="eCartSMC_1_ATC" id="eCartSMC_1_ATC">Proceed to Payment <i class="fal fa-shopping-cart"></i></button>
</form>
And it's corresponding server behaviour...
<?php
// WA eCart AddToCart
if (isset($_POST["eCartSMC_1_ATC"]) || isset($_POST["eCartSMC_1_ATC_x"])) {
$ATC_itemID = $_SESSION["eCartSMC_OrderID"];
$ATC_AddIfIn = 4;
$ATC_RedirectAfter = "../health-screening-form-checkout.php";
$ATC_RedirectIfIn = "";
$ATC_itemName = "Sports Medical Certificate Form Ref ". $rsEDITFORM->getColumnVal("SMCformID") ."";// column binding
$ATC_itemDescription = "Order Ref SMC". $rsEDITFORM->getColumnVal("SMCorderID") ."";// column binding
$ATC_itemThumbnail = "";// column binding
$ATC_itemWeight = floatval("0");// column binding
$ATC_itemQuantity = floatval("1");// column binding
$ATC_itemPrice = floatval("65");// column binding
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$eCartSMC->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemThumbnail, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice);
if ($ATC_RedirectAfter != "" && $eCartSMC->redirStr == "") {
$eCartSMC->redirStr = $ATC_RedirectAfter;
}
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
}
else {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];
}
}
}
?>
Is the $ATC_itemID the invoice ID that PayPal uses or is this the product ID?
I believe that it's the later form that's causing the problems because people are arriving at PayPal but are sometimes dumped out at that stage.
Therefore, it could be that $_SESSION["eCartSMC_OrderID"]; is wiped and PayPal has nothing to work with?
I would appreciate clarification on $ATC_itemID as if that's the invoice ID then I should probably look to make that:
$ATC_itemID = ". $rsEDITFORM->getColumnVal("SMCorderID") .";
Thank you.
NJ