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>
Update:
i have found something like this to save the last x Url's in array, maybe someone can tell me how I can adapt this for my code? Thank you
$urlHistory = (array) Mage::getSingleton('core/session')->getMyUrlHistory();
while (is_array($urlHistory) && count($urlHistory) > 3) {
array_shift($urlHistory);
}
$urlHistory[] = Mage::helper('core/url')->getCurrentUrl();
Mage::getSingleton('core/session')->setMyUrlHistory($urlHistory);
Anyone?