在header.phtml或者head.phtml或者controllers文件中添加如下代碼
<?php
if (!Mage::getSingleton("customer/session")->isLoggedIn() && strpos(Mage::getBlockSingleton('page/html')->getBodyClass(),'checkout')){
$session = Mage::getSingleton("customer/session");
// Store The Current Page Url Where User will be redirected once loggedin
$session->setBeforeAuthUrl(Mage::helper("core/url")->getCurrentUrl());
$customerLoginURL = $this->getBaseUrl() . "customer/account/login";
Mage::app()->getFrontController()->getResponse()->setRedirect($customerLoginURL)->sendResponse();
}
?>