View Full Version : retaining form values in checkout
russell_m89943
04-20-2009, 01:24 PM
I was wondering if there was a way to retain form field values when a user goes back to edit information before making an order. My purchase looks like this:
1. checkout form (credit card info, bill address, etc)
2. review information
3. Submit order
If the user finds something they need to change in step 2 I'd like to be able to go back to step 1 but with the form already filled in with the previous information. I tried adding something like this to the value field: <?php echo $_SESSION['eCartCheckoutForm_cc_number']; ?> but it's showing up blank with an empty value when I view source.
Actually, on the same topic I think, is it possible to have the purchase information show up in the success page so they can print their order info for their records? I can't seem to find any session info in my success page.
Ray Borduin
04-20-2009, 01:33 PM
The values should be stored as session variables, I think if you set the field value to the session it should work. If you refresh the page does it then fill in?
It might be because it uses a history.back() to navigate back?
russell_m89943
04-20-2009, 01:45 PM
Didn't work, I've tried adding values from both the "session" bindings list and the "ecart_checkout_form" bindings but both are giving me blank forms, even on refresh.
Test case for session:
<input type="text" name="cc_number" id="cc_number" value="<?php echo $_SESSION['eCartCheckoutForm_cc_number']; ?>" />
Test case for checkout form:
<input type="text" name="firstname" id="firstname" value="<?php echo((isset($_POST["firstname"]))?$_POST["firstname"]:"") ?>" />
If I were using the checkout wizard would these values stick they I'm trying to get them to work?
Ray Borduin
04-20-2009, 02:38 PM
Do you have:
<?php session_start(); ?>
on top of the page?
russell_m89943
04-20-2009, 04:10 PM
I added it but that didn't seem to do the trick. Here's all the PHP I have at the top right now:
<?php session_start(); ?>
<?php
//WA eCart Include
require_once("../WA_eCart/bellaCart_PHP.php");
?>
<?php
$bellaCart->GetContent();
?>
<?php
require_once("../WA_eCart/PP_ECO_Scripts/PP_ECO_PHP.php");
?>
<?php
require_once("../WA_eCart/Adv_CO_Scripts/PP_DirectPayment_PHP.php");
?>
Should I make sure that session command is in all the checkout pages?
Ray Borduin
04-20-2009, 04:13 PM
actually if you have a session based cart on the page it already has the session started. I just can't figure out why it wouldn't be populating the fields from the session. Are you sure you are using the correct session variable names?
russell_m89943
04-21-2009, 11:13 AM
Pretty sure I'm grabbing the right variables, I'm just dragging them from the session bindings menu into the code (see attached for a partial list of the elements I'm using)
For the review page I'm actually populating the review text with the ecart_checkout_form variables, when I try to use the session variables there nothing shows up either. It would seem that the session is there in the binding but it's not populating at any point. I also checked my other eCart enabled pages and they all feature the same session bindings indicated in the attached image file. Maybe there's some sort of disconnect between the bindings and my code because I haven't been using the wizard?
Ray Borduin
04-21-2009, 11:17 AM
Yes, if you run the wizard once on your site, it always thinks the session variables are set even if you deleted those pages and start over. I would say you probably have to set the session variables on the confirm page so that you can use them to populate the checkout page when they go back.
russell_m89943
04-21-2009, 01:08 PM
That makes sense, here comes the dumb question: how would I set those session variables? And would those vars be available to me after I've completed the transaction with my payment gateway so I can present the user with a proper receipt? (I assume yes on the 2nd point but figured I'd ask anyway)
I also know I've said this before but I really appreciate the help, you're saving me hours on a project I underbid on in the first place. New lesson learned, don't give friends a professional discount ;-)
Ray Borduin
04-21-2009, 01:20 PM
On your confirm page, go to bindings and add the Form from the checkout page.
Then use the server behavior in the Ecart General Category to save the session variables. You will have to apply it once for each field you want stored. Just use the current session variable names since they aren't being used.
toni272059
03-12-2012, 09:31 AM
I am having the same trouble. Cannot get Checkout page form field values to stay when someone selects Modify Info on Confirm Page to go back to Checkout. All fields are empty.
I can get the fields to remain populated when first filling out the form after a validation error, but after Checkout button is clicked the data is gone when go back
I have tried adding the Checkout Form to the Confirm page bindings and adding session variables but nothing works. Tried trigger as any form post and dynamically linking to form field. Nothing, blank fields when go back.
I have tried both session variables and dynamic text fields on the Checkout page to mimic the setup on the Confirm page. Nothing works and I am totally confusing myself!
Screen grabs attached
Jason Byrnes
03-13-2012, 11:40 AM
you will need to add code to the initial value to check if the validated entries is set. send a copy of the checkout page and I can give an example.
toni272059
03-14-2012, 05:35 AM
checkout page attached. Thanks
Jason Byrnes
03-14-2012, 01:20 PM
this checkout form does not seem to have the code for the validated entries applied to the initial values.
are you only using client side validation or both client and server validation?
If you are only using client validation, then you only need to set the initial value of the form elements to use the session variable.
select a form element in design view, in the property inspector, click the lightning bolt next to initial value, expand the session collection, the select the corresponding session variable.
toni272059
03-14-2012, 03:04 PM
The form elements for the Billing Information have a session variable added.
Dynamic Text Field (firstname)
<input type="text" name="firstname" id="firstname" value="<?php echo((isset($_POST["firstname"]))?$_POST["firstname"]:"") ?>" />
When this did not work I tried adding from the Confirm Page
eCart Set Session Value (eCartCheckoutForm_firstname)
<?php
if (!session_id()) session_start();
if((((isset($_POST["firstname"]))?$_POST["firstname"]:"") != "")) {
$_SESSION["eCartCheckoutForm_firstname"] = "".((isset($_POST["firstname"]))?$_POST["firstname"]:"") ."";
}
?>
So both show in the Server Behaviors as
eCart Set Session Value (eCartCheckoutForm_firstname)
Dynamic Text Field (firstname)
The Form Validation is setup for fields in both Billing and Shipping and works. screen grab attached.
Thanks!
Jason Byrnes
03-14-2012, 03:18 PM
my point, though, is that initial values are set to use post data:
<input type="text" name="firstname" id="firstname" value="<?php echo((isset($_POST["firstname"]))?$_POST["firstname"]:"") ?>" />
but should be set to use the sessions instead:
<input type="text" name="firstname" id="firstname" value="<?php echo((isset($_SESSION["eCartCheckoutForm_firstname"]))?$_SESSION["eCartCheckoutForm_firstname"]:"") ?>" />
the form element initial values need to use the sessions that are created.
toni272059
03-15-2012, 05:32 AM
Got it! Thanks again!!
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.