问题
There are a number of pages that require a customer to log in to view them. How would I do this for the cart page /index.php?route=checkout/cart
回答1:
I think you mean you want to have a customer login if they go to the cart page correct? If so, here's how you do it. Open /catalog/controller/checkout/cart.php and find this line
public function index() {
Below this line, add the following code
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('checkout/cart', '', 'SSL');
$this->redirect($this->url->link('account/login', '', 'SSL'));
}
回答2:
for 2.xx, you need add response->redirect() instead of redirect()
like this
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('checkout/cart', '', 'SSL');
$this->response->redirect($this->url->link('account/login', '', 'SSL'));
}
来源:https://stackoverflow.com/questions/20074123/opencart-force-login-when-see-cart-page