cancel
Showing results for 
Search instead for 
Did you mean: 

Redirect Registered Customer issue

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

Redirect Registered Customer issue

Hi,
I add this condition on the Proceed to Checkout button:

<?php if ($this->isPossibleOnepageCheckout() && Mage::getSingleton('customer/session')->isLoggedIn()):?>
    <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Proceed to Checkout')) ?>" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="window.location='<?php echo $this->getCheckoutUrl() ?>';"><span><span><?php echo $this->__('Proceed to Checkout') ?></span></span></button>
<?php else: ?>
    <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Proceed to Checkout')) ?>" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="window.location='<?php echo Mage::getUrl('customer/account/login'); ?>';"><span><span><?php echo $this->__('Proceed to Checkout') ?></span></span></button>
<?php endif?>

So when a user is not login on my store will be redirected to Login / Register page. I made a custom function to redirect the customers after register to checkout page if the was in Shopping Cart else redirect to My Account. But I don't know what is wrong, because now after register I am redirect only to My Account. So I want to redirect customer after registration to the Checkout page if the customer was in the Shopping Cart else to My Account. This is my function:

 

   public function customerRegistration(Varien_Event_Observer $observer)
   {
      if(Mage::getSingleton('core/session')->getIsFromCart() == 1 || Mage::getSingleton('core/session')->getIsFromCheckout() == 1){
            Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('onestepcheckout/index'));
            Mage::app()->getResponse()->sendResponse();
            exit;
         }
    else
        {
            Mage::app()->getFrontController()->getResponse()->setRedirect(Mage::getUrl('customer/account'));
            Mage::app()->getResponse()->sendResponse();
            exit;
        }
         Mage::getSingleton('core/session')->setIsFromCart('0');
    Mage::getSingleton('core/session')->setIsFromCheckout('0');
   }

and this is my observer in the config.xml

    <customer_register_success>
        <observers>
          <customerredirect>
            <class>customerredirect/observer_customer</class>
            <method>customerRegistration</method>
          </customerredirect>
        </observers>
    </customer_register_success>

Thank you very much

 

Update:

Someone told me that is a way to do this. To add an event before going to register page, add an event observer after registration is complete and then check what is necessary. But I don't know to do this, maybe someone can help me with this?

 

New Update:

I found what is the problem: I check if the Last url was shopping cart and then I add some condition, for login when I check the last url is the shopping cart, but in register.phtml when I check if the LastUrl is Shopping cart is false, because there the LastUrl is login, how I can make this check to work on the register.phtml? In fact I need to check back for third Url.
Thank you

2 REPLIES 2

Re: Redirect Registered Customer issue

Login to Magento Admin --> System --> Configuration --> Sales -->Checkout -->Allow Guest Checkout --> Set to "No"

 

And you can revert all the above changes. Because Magento will redirect the user to login or register. 

Re: Redirect Registered Customer issue

Hi,

thank you for your answer but I want to tell you  Login to Magento Admin --> System --> Configuration --> Sales -->Checkout -->Allow Guest Checkout --> is Set to "No" already in my store, but my checkout page is not a default Magento. My checkout page need authentication in the checkout one page and I need to remove that authentication. For that I add that condition in the link.phtml on the Proceed to Checkout button, for that I need this code to work. Will be very fine if you can tell me a solution. Thank you.