Opencart Force login when see Cart Page?

房东的猫 提交于 2019-12-24 14:19:18

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!