close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Adding to cart, but not carrying recordset values in item name or description?

Thread began 6/28/2019 1:06 pm by Nathon Jones Web Design | Last modified 10/16/2019 4:41 pm by Ray Borduin | 172 views | 7 replies |

Nathon Jones Web Design

Adding to cart, but not carrying recordset values in item name or description?

When I click the Add to Cart button, it appears to add to cart but it's not bringing over the dynamic recordset values in the item name and dsecrption?

This is my add to cart code:

// WA eCart AddToCart
if (isset($_POST["eCartSMC_1_ATC"]) || isset($_POST["eCartSMC_1_ATC_x"])) {
$ATC_itemID = $rsEDITFORM->getColumnVal["SMCorderID"];
$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'];
}
}
}
?>



I've provided a link and instructions on how to replicate this in the thread below.
Hope you can help. Thank you.
NJ

Sign in to reply to this post

Nathon Jones Web Design

Link and details below. Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

Your recordset: $rsEDITFORM wasn't returning a result after the form submit. I updated it to fix the issue.

Sign in to reply to this post
Did this help? Tips are appreciated...

Nathon Jones Web Design

There is a still a problem here. It's carrying over the SMCformID and SMCorderID values to the subsequent page, health-screening-form-checkout.php, but when it gets there I have a recordset on that page that's supposed to pre-fill the billing information form.

The recordset is as follows:

<?php
$rsCONFIRMORDER = new WA_MySQLi_RS("rsCONFIRMORDER",$csdbmysqli,1);
$rsCONFIRMORDER->setQuery("SELECT SMCorders.*, SMCuser.*, userORDER.SMCuserFIRST AS USERORDERfirst, userORDER.SMCuserSUR AS USERORDERsur, userORDER.SMCuserUSER AS USERORDERemail, userORDER.SMCuserADD AS USERORDERadd, userORDER.SMCuserADD1 AS USERORDERadd1, userORDER.SMCuserCITY AS USERORDERcity, userORDER.SMCuserREGION AS USERORDERregion, userORDER.SMCuserZIP AS USERORDERzip, userORDER.SMCuserPHONE AS USERORDERphone, userORDER.SMCuserMOBILE AS USERORDERmobile, SMCcountries.SMCcountryID, SMCcountries.SMCcountryCODE, SMCcountries.SMCcountryNAME, SMCform.*
FROM SMCorders
INNER JOIN SMCuser ON SMCorders.SMCorderUSERID = SMCuser.SMCuserID
INNER JOIN SMCuser userORDER ON SMCorders.SMCorderUSERID = userORDER.SMCuserID
INNER JOIN SMCcountries ON userORDER.SMCuserCOUNTRY = SMCcountries.SMCcountryID
INNER JOIN SMCform ON SMCorders.SMCorderFORMID = SMCform.SMCformID
WHERE SMCorders.SMCorderID = ?");
$rsCONFIRMORDER->bindParam("i", "".(isset($_SESSION['eCartSMC_OrderID'])?$_SESSION['eCartSMC_OrderID']:"") ."", "-1"); //WAQB_Param1
$rsCONFIRMORDER->execute();
?>



This checkout page works for both new orders and returning orders so I need the order ID, in the above process, to also be set up as the eCartSMC_OrderID session. Is that possible?

Thank you.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

This could be an issue with the Session variable not being set correctly in the first place, or an issue with the query itself not returning a result.

I'd first confirm that the Session variable is being set and is available. Then I'd use:

<?php echo($rsCONFIRMORDER->debugSQL()); ?>

And then copy/paste the result into your phpMyAdmin to see if it has a result. I'm not sure if the session variable is the issue or the Query or how you have it populated on the page. If the query returns the correct result and the session appears to be set, then then issue is with how you are using the recordset to populate the form.

Sign in to reply to this post
Did this help? Tips are appreciated...

Nathon Jones Web Design

This is the Add to Cart button...

<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">Proceed to Payment <i class="fal fa-shopping-cart"></i></button>
</form>



I've got a hidden field called eCartSMC_1_ID_Add with the form ID value, <?php echo($rsEDITFORM->getColumnVal("SMCformID")); ?>, and this is directing to the health-screening-form-checkout.php page.

My recordset on health-screening-form.php is filtering by $_SESSION['eCartSMC_OrderID'] so perhaps that's why the value doesn't always carry over?

I'm confusing myself, as I type here.

Would a solution be to change my recordset to filter by $_SESSION['eCartSMC_OrderID'] OR $_POST['eCartSMC_OrderID']?
Is the Add to Cart behaviour event even a POST though?

Urggh. My brain is hurting.
Are you free to set up this IPN PayPal thing tomorrow, Thursday or Friday this week and perhaps we could iron out thigns like this whilst we're at it?

Cheers.
NJ

Sign in to reply to this post

Ray BorduinWebAssist

I should have time tomorrow. Send me a message via Skype to coordinate a time.

Sign in to reply to this post
Did this help? Tips are appreciated...

Nathon Jones Web Design

Thank you Ray.

The Add to Cart behaviour isn't posting my hidden form field value. My guess is that it's not supposed to.

I added a Set Session Value behaviour:

<?php
@session_start();
if (!isset($_SESSION["eCartSMC_OrderID"])) {
$_SESSION["eCartSMC_OrderID"] = "".($rsEDITFORM->getColumnVal("SMCorderID")) ."";
}
?>



...so that the session would defintely exist, prior to clicking the Add to Cart button. Sure enough, when I display this session value on the add to cart page it exists, and it's the correct number (the order ID from my Orders table).

Clicking the Add to Cart button takes the user to the card/billing address page (health-screening-form-checkout.php) and, on that page, I have the following recordset:

<?php
$rsCONFIRMORDER = new WA_MySQLi_RS("rsCONFIRMORDER",$csdbmysqli,1);
$rsCONFIRMORDER->setQuery("SELECT SMCorders.*, SMCuser.*, userORDER.SMCuserFIRST AS USERORDERfirst, userORDER.SMCuserSUR AS USERORDERsur, userORDER.SMCuserUSER AS USERORDERemail, userORDER.SMCuserADD AS USERORDERadd, userORDER.SMCuserADD1 AS USERORDERadd1, userORDER.SMCuserCITY AS USERORDERcity, userORDER.SMCuserREGION AS USERORDERregion, userORDER.SMCuserZIP AS USERORDERzip, userORDER.SMCuserPHONE AS USERORDERphone, userORDER.SMCuserMOBILE AS USERORDERmobile, SMCcountries.SMCcountryID, SMCcountries.SMCcountryCODE, SMCcountries.SMCcountryNAME, SMCform.*
FROM SMCorders
INNER JOIN SMCuser ON SMCorders.SMCorderUSERID = SMCuser.SMCuserID
INNER JOIN SMCuser userORDER ON SMCorders.SMCorderUSERID = userORDER.SMCuserID
INNER JOIN SMCcountries ON userORDER.SMCuserCOUNTRY = SMCcountries.SMCcountryID
INNER JOIN SMCform ON SMCorders.SMCorderFORMID = SMCform.SMCformID
WHERE SMCorders.SMCorderID = ?");
$rsCONFIRMORDER->bindParam("i", "".(isset($_SESSION['eCartSMC_OrderID'])?$_SESSION['eCartSMC_OrderID']:"") ."", "-1"); //WAQB_Param1
$rsCONFIRMORDER->execute();
?>



This recordset is returning a record, because I have it populating the billing address fields. However, the cart summary section at the bottom has omitted the form ID and order ID, despite them being set in the Add to Cart behaviour on the previous page (itemName and itemDescription):

<?php
// WA eCart AddToCart
if (isset($_POST["eCartSMC_1_ATC"]) || isset($_POST["eCartSMC_1_ATC_x"])) {
$ATC_itemID = $rsEDITFORM->getColumnVal["SMCorderID"];
$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'];
}
}
}
?>



My conclusion is that this is nothing to do with the session values, it is simply that the Add to Cart behaviour is not allowing/storing the recordset values specified in the itemName and itemDescription sections, which is why they are not displaying in the cart summary section on the subsequent page. That's an issue that I can't resolve without your help.

Will Skype message you around 5pm GMT.
Thank you.
NJ

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...