Jump to content



Latest News: (loading..)

- - - - -

Take Visitor to Checkout instead of Home Page after login/create account


This topic has been archived. This means that you cannot reply to this topic.
36 replies to this topic

#21   spooks

spooks
  • Members
  • 7,017 posts

Posted 26 March 2010 - 08:29 PM

View Postaxioma, on 26 March 2010 - 08:26 PM, said:

Hello, yes I test on 2 stores, one on a fresh installation without modification, and one on another store with this modification.


The goal is  go to my account. This 2 sceneries are present:

The standard store lead me to directly to my account after I login

The modified store lead me to directly to shopping after I login (note: my cart is empty, I did not put anything to my shopping cart).


Then you made an error, on my sites with this (rc2a etc) it does as expected.
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#22   axioma

axioma
  • Members
  • 168 posts

Posted 29 March 2010 - 06:33 PM

Yes is something wrong in my store.
After made the modifications to my store an a vanilla store, and after use compare files  

loging.php files are similar  
create_account.php files are similar  
even create_account_success.php files are similar  
I don’t know where is my error…

#23   spooks

spooks
  • Members
  • 7,017 posts

Posted 29 March 2010 - 06:48 PM

View Postaxioma, on 29 March 2010 - 06:33 PM, said:

I don’t know where is my error…


In an edited login.php ushould now have:

 

// restore cart contents
		$cart->restore_contents();

		if (sizeof($navigation->snapshot) > 0) {
	  	$origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
	  	$navigation->clear_snapshot();
	  	tep_redirect($origin_href);
		} else {
			 if ($cart->count_contents() < 1) {	
	 		tep_redirect(tep_href_link(FILENAME_DEFAULT));   
   		 } else {   
	 		tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, 'info_message=' . 'Welcome back, You have been logged in successfully!', 'SSL'));   
		 }
   	}




that code means if there is a page history, go there, otherwise if items in cart, go there, otherwise index.php

perhaps you have brackets miss positioned, that would drastically alter the behaviour.
Sam

Remember, What you think I ment may not be what I thought I ment when I said it.

Contributions:


Auto Backup your Database, Easy way

Multi Images with Fancy Pop-ups, Easy way

Products in columns with multi buy etc etc

Disable any Category or Product, Easy way

Secure & Improve your account pages et al.

#24   axioma

axioma
  • Members
  • 168 posts

Posted 29 March 2010 - 08:00 PM

this is my code

// restore cart contents
 	$cart->restore_contents();

 	if (sizeof($navigation->snapshot) > 0) {
 	$origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']);
 	$navigation->clear_snapshot();
 	tep_redirect($origin_href);
 	} else {
 	if ($cart->count_contents() < 1) { 	tep_redirect(tep_href_link(FILENAME_DEFAULT)); } else { tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, 'info_message=' . 'Welcome back, You have been logged in successfully!', 'SSL')); }
 	}
 	}
	}
 }

 if ($error == true) {
	$messageStack->add('login', TEXT_LOGIN_ERROR);

is there an extra brackets?

thnks

#25   birdrockdesigns

birdrockdesigns
  • Members
  • 77 posts

Posted 27 May 2010 - 07:16 AM

View Postspooks, on 05 March 2010 - 12:02 PM, said:

This came up & others may find it useful, so I`m repeating the tip here:


After a visitor has placed an item in thier cart and has to sign in or create a account, they go back to the index page and not to the shopping cart where they came from.


This first change means after your visitor logs in, if there are items in the cart, instead of going to the home page they go staight to checkout and get a message for displayed on checkout that they are logged in:

In login.php

find:

tep_redirect(tep_href_link(FILENAME_DEFAULT));

replace with:

if ($cart->count_contents() < 1) {	tep_redirect(tep_href_link(FILENAME_DEFAULT));   } else {   tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, 'info_message=' . 'Welcome back, You have been logged in successfully!', 'SSL'));   }

This next change means after your visitor completes the create account page if there are items in their cart, instead of going to CREATE_ACCOUNT_SUCCESS, they go staight to checkout and have a message displayed on checkout that the account is created:

In create account find:

tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));


replace with:

if ($cart->count_contents() < 1) {	tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));   } else {   tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, 'info_message=' . 'Welcome! Your new account has been successfully created!', 'SSL'));   }




Another change I make is if your visitor has no items in thier cart & they click on checkout, they are taken to the login page, in my view this is not what they expect, so this change means if they click on checkout with nothing in thier cart they go to the cart.

in checkout_shipping.php:

find:

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($cart->count_contents() < 1) {
	tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));

move that section to above:

// if the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
	$navigation->set_snapshot();
	tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }


Thats it, hope you find this useful. [img]http://forums.oscommerce.com/public/style_emoticons/default/biggrin.gif[/img]


Sam, this is brilliant!  Thanks so much.

Don't know if this is the right thread, but do you know how to get the Complete Reviews System to work with a CSS osCommerce install? I keep getting syntax errors - and I've looked through the code. I have to remove any 'table' tags like <td> or <tr> - and the instructions aren't too clear.

http://addons.oscommerce.com/info/4397

Any help would be much appreciated.

Thanks.

#26   BRD-75

BRD-75
  • Members
  • 11 posts

Posted 04 November 2010 - 03:10 AM

View Postspooks, on 05 March 2010 - 12:02 PM, said:


In login.php

if ($cart->count_contents() < 1) {	tep_redirect(tep_href_link(FILENAME_DEFAULT));   } else {   tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, 'info_message=' . 'Welcome back, You have been logged in successfully!', 'SSL'));   }

I added this code however, I changed it to FILENAME_SHOPPING_CART instead of FILENAME_CHECKOUT_SHIPPING and it works great as long as the item added is in the member's cart from previous log-in. Welcome message also displays correctly.

If there is an item added to the visitor's cart before log-in it always redirects to checkout_shipping.php after the visitor/member cart merge even if there was no item in the members cart from a previous log-in. In this case, the welcome message is also not displayed.

Where can I find the "cart merge" code that I assume has a redirect? I would like to use this code above to force log-ins with visitor cart contents >0 to the shopping cart as well.

The issue I see is that a customer (forgetting that they previously added to their member's cart) will be confused when they arrive to the shipping page and they see shipping at a cost greater then the item(s) they just added to the visitor cart. They then wouldn't see the additional items in their now merged cart until they reach the confirm page unless they click out of the checkout process. Neither my shipping or payment pages show cart contents, quantities or item prices.

Edited by BRD-75, 04 November 2010 - 03:11 AM.


#27   BRD-75

BRD-75
  • Members
  • 11 posts

Posted 04 November 2010 - 08:10 AM

After re-reading the first post in this thread and going thru my checkout process a couple more times I'm gonna try and reword it a little.

View Postspooks, on 05 March 2010 - 12:02 PM, said:

After a visitor has placed an item in thier cart and has to sign in or create a account, they go back to the index page and not to the shopping cart where they came from.

My setup never directed you to the index page or back to the shopping cart after being forced to log in. It sent you on to where the button you click in the shopping cart to check out would have sent you had you been logged in, checkout_shipping.php. If you clicked the button and then had to create an account it would then send you to the account confirmation page where you would click continue and then you were finally directed to the index page.

My code in the login.php was the same.
tep_redirect(tep_href_link(FILENAME_DEFAULT));

By replacing with this:
if ($cart->count_contents() < 1) {	tep_redirect(tep_href_link(FILENAME_DEFAULT));   } else {   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'info_message=' . 'Welcome back, You have been logged in successfully!', 'SSL'));   }

it allowed for the user to see their updated cart after the visitor's and member's carts merge at log-in but it only works if your using the login.php button. Using the "Checkout" button (checkout_shipping.php) in either cart always either takes you directly or redirects you after log-in to the shipping page no matter what you had in either cart or how you change the code in login.php.

In fact, if your not logged in there is no checkout button anywhere until you add something to your cart so there is no need or anything fixed by the 3'rd change on this post unless I'm missing something. If somehow someone ended up on checkout with nothing in their cart wouldn't it automatically show empty cart?

View Postspooks, on 05 March 2010 - 12:02 PM, said:

Another change I make is if your visitor has no items in thier cart & they click on checkout, they are taken to the login page, in my view this is not what they expect, so this change means if they click on checkout with nothing in thier cart they go to the cart.

in checkout_shipping.php:

find:

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($cart->count_contents() < 1) {
	tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));

move that section to above:

// if the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
	$navigation->set_snapshot();
	tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }

I need something like this that says if checkout_shipping.php is clicked while in cart and user is not logged in redirect back to cart after log-in. Instead somewhere it's saying to continue on to shipping after log-in and i don't see anything like that in the login.php file.

By reading what others have asked it looks like many have had the same issues but I didn't find anyone asking it exactly. So far the closest solution I found was to have it clear the member's cart feature after log-out so there wouldn't be a hidden merge with no chance to review the updated cart before you land on checkout_shipping.

Another solution would be if I could figure out how to show cart totals with an edit button on the shipping page like it does on the confirmation page and then cart and shipping on the payment page. Ideally if each page thru the checkout process would stack on the previous page's info all the way to the confirmation page it would make it a lot more user friendly for the consumer.

Edited by BRD-75, 04 November 2010 - 08:21 AM.


#28   tigergirl

tigergirl
  • Members
  • 423 posts

Posted 04 November 2010 - 09:25 AM

View PostBRD-75, on 04 November 2010 - 08:10 AM, said:

Using the "Checkout" button (checkout_shipping.php) in either cart always either takes you directly or redirects you after log-in to the shipping page no matter what you had in either cart or how you change the code in login.php.

In fact, if your not logged in there is no checkout button anywhere until you add something to your cart so there is no need or anything fixed by the 3'rd change on this post unless I'm missing something. If somehow someone ended up on checkout with nothing in their cart wouldn't it automatically show empty cart?


I need something like this that says if checkout_shipping.php is clicked while in cart and user is not logged in redirect back to cart after log-in. Instead somewhere it's saying to continue on to shipping after log-in and i don't see anything like that in the login.php file.


If you look in the default version of checkout_shipping.php, you would have this code:
// if the customer is not logged on, redirect them to the login page
 if (!tep_session_is_registered('customer_id')) {
	$navigation->set_snapshot();
	tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

// if there is nothing in the customers cart, redirect them to the shopping cart page
 if ($cart->count_contents() < 1) {
	tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
 }

If customer is not logged in it will take them to login.php and then shopping cart if nothing in basket. Take a look at what you have in checkout_shipping which is making it behave the way you describe.

If you don't have the checkout button when cart is empty, it seems like you have a modification installed. I think "More Logical Checkout" hid the "checkout" link, might be worth a look. I personally didn't like that little bit as I felt the customer may have saved their basket previously and want to click "checkout" so I didn't use that part of code. I think I used "Faster Checkout" which removes "checkout success" redundant page if items in cart.

There are a lot of tweaks but you have to find one that suits you and that may involve combining different contributions. There is a mod that alters checkout to show shopping cart during checkout, could be "2 step checkout" not sure though.
I'm feeling lucky today......maybe someone will answer my post!
I do try and answer a simple post when I can just to give something back.
------------------------------------------------
PM me? - I'm not for hire

#29   BRD-75

BRD-75
  • Members
  • 11 posts

Posted 04 November 2010 - 11:36 PM

Thanks tigergirl, my version of checkout_shipping.php was the same which led to to compare the code in Checkout_process which was the same example from this post but it had extra code using snapshot to redirect after log in. I added it to my checkout_shipping and chose to send people back to their cart after the merge of the two carts.

I used
// if the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
	$navigation->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_SHOPPING_CART));
	tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

View Posttigergirl, on 04 November 2010 - 09:25 AM, said:

If you don't have the checkout button when cart is empty, it seems like you have a modification installed. I think "More Logical Checkout" hid the "checkout" link, might be worth a look.

It looks like the buy now button has been used as an add to cart button unless default has both and my buy now/checkout button has been disabled. I like that there isn't a checkout button without something in your cart but I might consider adding a view cart button on my product pages. I haven't searched for tips on that yet.

View Posttigergirl, on 04 November 2010 - 09:25 AM, said:

There are a lot of tweaks but you have to find one that suits you and that may involve combining different contributions. There is a mod that alters checkout to show shopping cart during checkout, could be "2 step checkout" not sure though.
Now that my redirect is working I'll check into this. It would be nice to show each step of checkout build up as you go thru the process.

Thanks again, I appreciate the help.

#30   Boom

Boom
  • Members
  • 57 posts

Posted 17 December 2010 - 05:11 PM

View Postspooks, on 05 March 2010 - 12:02 PM, said:

This came up & others may find it useful, so I`m repeating the tip here:

These tips were utterly brilliant in their use and simplicity. Thank you so much Sam. I incorporated all of them into our online store with absolutely zero problems.

Boom

#31   Fourpaws

Fourpaws
  • Members
  • 57 posts

Posted 18 February 2011 - 03:20 PM

Great tip, thanks Sam.

Where is it picking up the message background and font color from? I would like to change it.

#32   ThomasG

ThomasG
  • Members
  • 2 posts

Posted 06 April 2011 - 07:02 AM

Hey :)

Works perfect, thank you!

I tried to modify the code a little bit to adapt the info_message, since my store is in french and english... but no success as I am a php newbie :P

Can someone give me a little help plz?

#33   Krikie

Krikie
  • Members
  • 1 posts

Posted 07 April 2011 - 01:26 PM

Related to

This first change means after your visitor logs in, if there are items in the cart, instead of going to the home page they go staight to checkout and get a message for displayed on checkout that they are logged in:

In login.php

find:

tep_redirect(tep_href_link(FILENAME_DEFAULT));



replace with:

if ($cart->count_contents() < 1) {      tep_redirect(tep_href_link(FILENAME_DEFAULT));   } else {   tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, 'info_message=' . 'Welcome back, You have been logged in successfully!', 'SSL'));   }


For me it doesn't work, could you please check my code (I changed checkout_shipping to shopping_cart) but the user is not directed to the cart page after login if he has something in his cart.

Secondly: How do you handle the textmessages if you have a multilanguage site?

Code

} else {
          if ($cart->count_contents() < 1) {      tep_redirect(tep_href_link(FILENAME_DEFAULT));   } else {   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'info_message=' . 'Welkom terug, U bent opnieuw ingelogd en kan uw bestelling verder afwerken indien u wenst!', 'SSL'));   }

        }
      }
    }
  }

if ((isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process'))

#34   ThomasG

ThomasG
  • Members
  • 2 posts

Posted 10 April 2011 - 10:26 AM

@Krikie

I have finally been able to adapt the info_message, to show it in french or in english. Here is the guideline (included your modification to redirect to shopping_cart instead of checkout shipping)

In login.php

find:

tep_redirect(tep_href_link(FILENAME_DEFAULT));


replace with:

if ($cart->count_contents() < 1) {	  tep_redirect(tep_href_link(FILENAME_DEFAULT));   } else {   tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'info_message=' . WELCOME_TEXT, 'SSL'));   }

In includes/languages/english.php, insert the following line before the ending ?>

define('WELCOME_TEXT', 'Welcome back, You have been logged in successfully!');

In includes/languages/nederlands.php I guess, or whatever your other language name, also define WELCOME_TEXT by putting before the ending ?>

define('WELCOME_TEXT', 'Welkom terug, U bent opnieuw ingelogd en kan uw bestelling verder afwerken indien u wenst!');

Enjoy ;)

Edited by ThomasG, 10 April 2011 - 10:27 AM.


#35   mghay

mghay
  • Members
  • 34 posts

Posted 24 September 2011 - 02:11 PM

Thanks Sam for the basic tip.

I needed the info msg in different language as well as English and like ThomasG managed that tweak, BUT... discovered that any punctuation or accented letters would not display (no ',' or '!' in English version and no 'é' etc even when using 'é').

Also, any way of adjusting the text formatting or background colour?

Thanks,
Mike

#36   crosscomms

crosscomms
  • Members
  • 4 posts

Posted 09 November 2011 - 02:54 PM

I hope some help can be given here

I tried to make the changes to the login and i now know that i editted the wrong text instead of editting and replacing the below,
find:
tep_redirect(tep_href_link(FILENAME_DEFAULT));
I editted a line that i am sure contained the word cookies - now when a customer who is not logged in goes to the checkout i get an ssl error on the internet connection
reading
Secure Connection Failed
  
  
  
  
  
    
    
  An error occurred during a connection to crosscommsdistribution.co.uk.

SSL received a record that exceeded the maximum permissible length.

(Error code: ssl_error_rx_record_too_long)

    

    
    

  The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
  Please contact the web site owners to inform them of this problem. Alternatively, use the command found in the help menu to report this broken site.

The file currently reads this
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled (or the session has not started)
  if ($session_started == false) {
if ($cart->count_contents() < 1) {   tep_redirect(tep_href_link(FILENAME_DEFAULT));   } else {   tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING, 'info_message=' . 'Welcome back, You have been logged in successfully!', 'SSL'));   }
  }

Can anyone please help me get this line back to what it was before i messed it up.

Thank you

#37   14steve14

14steve14

    STORE OWNER NOT CODER

  • Members
  • 3,113 posts

Posted 18 November 2011 - 05:44 PM

Upload the backup you made before you editted the file, or use the standard file that comes with your copy of oscommerce.
REMEMBER BACKUP, BACKUP AND BACKUP
I am not a coder, so dont bother sending PMs asking for help as you wont get any.  

OSC has a steep learning curve, but in general the program does work.  If it doesnt work, the chances are it is something you have done.