coffman Posted November 17, 2006 Posted November 17, 2006 I am really in need of help in understanding the checkout process. I previously posted about this here: http://www.oscommerce.com/forums/index.php?sho...=145361&hl= But have gotten no recent replies so I am trying a new thread.... My customers intermittently end up in the shopping cart after confirming their order and I need some help in understanding what is going on behind the scenes in the checkout process. I have reduced the problem to the following: Intermittently, when a customer clicks on the confirmation button on the checkout_confirmation.php page, they end up back in the shopping cart instead of the checkout_success.php page. To debug the problem, I placed code at the top of each of the checkout_* pages along with the application_top.php file and some additional similar tracking code elsewhere in the *.php file so I new when a new page was being called or something else significant seemed to be happening: $fn= '/tmp/debug-log'; //DEBUG $fh = fopen($fn,'a'); //DEBUG fwrite($fh,"checkout_confirmation.php: refer = $HTTP_REFERER\n"); //DEBUG fwrite($fh,"checkout_confirmation.php: top\n"); //DEBUG I replace the checkout_confirmation.php above with the actual file name that the statements are in. I also added similar print statments to the tep_redirect function to track which page was being called next. When the checkout ends up on the checkout_success.php page, my logging output looks like the following: checkout_process.php: Call checkout_success.php - redirect functions/general.php: https://www.suncreekmusic.com/ts/checkout_success.php functions/general.php: 2 - Location: https://www.suncreekmusic.com/ts/checkout_success.php functions/general.php: 3 - Location: https://www.suncreekmusic.com/ts/checkout_success.php checkout_success.php: top When the checkout ends up in the shopping cart, the logging output looks like the following: checkout_process.php: Call checkout_success.php - redirect functions/general.php: https://www.suncreekmusic.com/ts/checkout_success.php functions/general.php: 2 - Location: https://www.suncreekmusic.com/ts/checkout_success.php functions/general.php: 3 - Location: https://www.suncreekmusic.com/ts/checkout_success.php checkout_process.php: refer = https://www.suncreekmusic.com/ts/checkout_confirmation.php checkout_process.php: top In both of the above, the funtions/general.php lines indicate prints of $url in tep_redirect before and after the header call. And the checkout_process.php line is a simple print right before the tep_redirect call to checkout_success.php. My question, how in the heck can I call tep_redirect with checkout_success.php as the destination URL value and then end up back in checkout_process.php? Are there things set in the background that affect this? Is there some voodoo magic happening in the header call? I am really confused here. When I do something similar just using a couple of test.php files, the header call works everytime without fail. Please, if you have any ideas I would greatly appreciate them. Even random speculation or clarifying questions are welcome. Here is what my logging version of tep_redirect looks like: // Redirect to another page or site function tep_redirect($url) { //DEBUG $fn= '/tmp/debug-log'; $fh = fopen($fn,'a'); fwrite($fh,"functions/general.php: $url\n"); //DEBUG if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url $url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL fwrite($fh,"functions/general.php: 1 - Location: $url\n"); //DEBUG } } fwrite($fh,"functions/general.php: 2 - Location: $url\n"); //DEBUG header('Location: ' . $url); fwrite($fh,"functions/general.php: 3 - Location: $url\n"); //DEBUG tep_exit(); fwrite($fh,"functions/general.php: 4 - Location: $url\n"); //DEBUG fclose($fh); } Here is what I have reduced checkout_success.php to: <?php $fn= '/tmp/debug-log'; //DEBUG $fh = fopen($fn,'a'); //DEBUG if($fh) { fwrite($fh,"checkout_success.php: top\n"); } ?> <html> <body> DEBUG 1 </body> </html> <?php if($fh) { fwrite($fh,"checkout_success.php: post html\n"); } //else { exit; } //exit; ?> -Michael -MichaelC
Guest Posted November 17, 2006 Posted November 17, 2006 If you look at the top of checkout_success.php you will find: if (!tep_session_is_registered('customer_id')) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART)); } It appears that you are losing the session Sonia
coffman Posted November 17, 2006 Author Posted November 17, 2006 Thanks for taking the time to reply. I have reduced my checkout_success.php file to: <?php $fn= '/tmp/debug-log'; //DEBUG $fh = fopen($fn,'a'); //DEBUG if($fh) { fwrite($fh,"checkout_success.php: top\n"); } ?> <html> <body> DEBUG 1 </body> </html> <?php if($fh) { fwrite($fh,"checkout_success.php: post html\n"); } //else { exit; } //exit; ?> And based on what I am capturing in my log file using fwrite statements, I never make it to the checkout_success.php when I have problems. I also forgot to mention that the shopping cart is empty when I get there. It basically makes it there by passing through checkout_process, checkout_payment and checkout_shipping... -Michael -MichaelC
Guest Posted November 17, 2006 Posted November 17, 2006 Is the order processed? The best that I can suggest is that you look at the possible redirects from checkout_process.php eg. if $sendto is not registered, you will be redirected to checkout payment and the same goes for $payment - I think the most likely cause is a faulty payment module. If you are redirected to checkout_payment and have also lost the $cart object, you will be returned to an empty cart Sonia
coffman Posted November 17, 2006 Author Posted November 17, 2006 That is kind of what I have been doing. I am using the basic cod payment option currently. I started by tracking the values of $sendto and seeing where and when it was set or not set, that is when I ended up seeing that when it entered the tep_redirect with one url, it ended up on a different page. I can't seem to get my brain beyond that. If I am sending header('Location: someurl'), would some kind of funkiness with session or cart keep me from landing at 'someurl'? What values can I dump while in the tep_redirect function to see if something is missing or being set incorrectly? ( would it just be the $_SESSION array info ?) Thanks again for the reponses... -MichaelC
Recommended Posts
Archived
This topic is now archived and is closed to further replies.