Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Take Visitor to Checkout Not Homepage after Login - 2.3.3.4


Mort-lemur

Recommended Posts

Posted

Hi,

 

Thought I would re-post the code changes below - they are from an archived post by Spooks back in 2010, but I have tried the changes on my 2.3.3.4 site and they work fine - In my view makes the behaviour more what would be expected:

 

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'));
 }

Now running on a fully modded, Mobile Friendly 2.3.4 Store with the Excellent MTS installed - See my profile for the mods installed ..... So much thanks for all the help given along the way by forum members.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...