dongxing7083 2013-12-22 21:29
浏览 39
已采纳

magento如何检查用户是否登录了订单页面

I am still pretty new to Magento, and I was wondering how Magento is checking if a user is logged in in the magento/index.php/sales/order/view/order_id/102/ page.

For example if a user who is not related to this order try to go there, he will be redirected to his own order history page. But I can't see this function neither in info.php nor in info.phtml in the sales/order directories (template and block).

I am asking this because I would like to use this feature as well.

  • 写回答

2条回答 默认 最新

  • douniwan_0025 2013-12-22 21:43
    关注

    The verification is done in the controller. The controller responsible for order details page is Mage_Sales_OrderController that extends Mage_Sales_Controller_Abstract. And in Mage_Sales_Controller_Abstract there is this method _canViewOrder that checks if the order has a visible status and if the order customer is the same as the logged in customer

    protected function _canViewOrder($order)
    {
        $customerId = Mage::getSingleton('customer/session')->getCustomerId();
        $availableStates = Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates();
        if ($order->getId() && $order->getCustomerId() && ($order->getCustomerId() == $customerId)
            && in_array($order->getState(), $availableStates, $strict = true)
            ) {
            return true;
        }
        return false;
    } 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100