close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Passing an additional variable from cart.php to checkout.php page

Thread began 10/02/2014 10:59 am by Justin@AdventDesign | Last modified 10/07/2014 10:53 am by Justin@AdventDesign | 11039 views | 14 replies |

Justin@AdventDesign

Passing an additional variable from cart.php to checkout.php page

I'm using the standard process from the checkout wizzard to generate orders for a franchise website (ecart 5). Currently when it rolls from the cart.php page to checkout.php page, the billing and shipping info is pulled from the user table. They wish to change the system so that one user is can order product for multiple locations which means I need to pull shipping and billing from a locations table, not the users table.

I have a relational table established identifying what users have control over what locations. I have a recordset pulled on the cart.php page, and it populates a drop menu within the form on the cart.php page.

Can anyone offer some direction how to pass that form input variable from the cart.php page to the checkout.php where I could then theoretically query a recordset with that variable to populate the billing and shipping information properly? The checkout process doesn't pass these variables in a URL string, which is what I'm familiar with.

I've attached the cart.php in case you need to reference it.

Attached Files
cart.php
Sign in to reply to this post

CraigRBeta Tester

could you not just save the variable from the cart page as a session variable, and use this value on the checkout page ?

http://www.w3schools.com/php/php_sessions.asp

Sign in to reply to this post

Justin@AdventDesign

Makes sense. I've been poking around trying to find specifics on how to do this, but I don't believe the session is setting properly and I'm not sure why. I have error reporting turned on on both pages.

On my cart.php page...

<?php
@session_start();
?>
is set on line 1

The form is set to 'post'

The select tag is properly identified as <select name="location" id="location"> and values are set properly on within the tag.

I have this php just following the closing form tag...
<?php
if (isset($_POST['Submit'])) {
$_SESSION['location'] = $_POST['location'];
}
?>

Upon submit it goes to the checkout.php page...

I have <?php echo 'Session: '.$_SESSION['location']; ?> in the body to check that the session variable is passing.

Returns the following error "Notice: Undefined index: location in /home/benspret/public_html/beta/corp/checkout.php on line 180" which is the line where the above echo statement is located.

Sign in to reply to this post

CraigRBeta Tester

try putting the

<?php
if (isset($_POST['Submit'])) {
$_SESSION['location'] = $_POST['location'];
}
?>

block towards the top of the page, before the //WA eCart Redirect Check Out block.

I suspect when you are submitting the form, you are being redirected to the checkout page before the session is set

(are you setting the session on submitting the 'checkout' form ?)

Sign in to reply to this post

Justin@AdventDesign

Tried that. Still doesn't seem to be setting. This is the redirect checkout block:


<?php
//WA eCart Redirect Check Out
if (isset($_POST["eCartMGP_Checkout"]) || isset($_POST["eCartMGP_Checkout_x"])) {
$Redirect_redirStr="checkout.php";
if ($Redirect_redirStr != "") {
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
if (strpos($Redirect_redirStr, "?") < 0) {
$Redirect_redirStr .= "?".$_SERVER['QUERY_STRING'];
}
else {
$Redirect_redirStr .= "&".$_SERVER['QUERY_STRING'];
}
}

$eCartMGP->redirStr = $Redirect_redirStr;
}
$eCartMGP->cartAction = "Checkout";
}
?>

I noticed the "eCartMGP_Checkout" and "eCartMGP_Checkout_x" as the $_POST so I tried doing this:

<?php
if (isset($_POST['eCartMGP_Checkout'])) {
$_SESSION['location'] = $_POST['location'];
}
?>

Still doesn't work.

Sign in to reply to this post

CraigRBeta Tester

I assume the location field is within the checkout form.

Can't see why it doesnt work, can you post your page ?

Sign in to reply to this post

Justin@AdventDesign

Yep. See attached.

Attached Files
cart.php
checkout.php
Sign in to reply to this post

Jason ByrnesWebAssist

your checkout button is a standard submit button. your trigger code:
if (isset($_POST['eCartMGP_Checkout_x'])) {

will only work for image element types. for a standard submit button, it needs to be:
if (isset($_POST['eCartMGP_Checkout'])) {

you may also want to add @session_commit();

<?php
if (isset($_POST['eCartMGP_Checkout'])) {
$_SESSION['location'] = $_POST['location'];
@session_commit();
}
?>

Sign in to reply to this post

Justin@AdventDesign

I had tried it both ways before, but just did again with the exact code you supplied above. Stil doesn't seem to be setting the session variable, unless my problem is on the checkout.php page retrieval.

Sign in to reply to this post

Jason ByrnesWebAssist

I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post
loading

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...