對於Magento,我仍然很陌生,我在想如何Magento檢查用戶是否登錄magento/index.php/sales/order/view/order_id/102/
頁面。magento如何檢查用戶是否已登錄訂購頁面
例如,如果與此訂單無關的用戶嘗試去那裏,他將被重定向到他自己的訂單歷史記錄頁面。但是我無法在info.php和sales/order目錄(模板和塊)中的info.phtml中看到這個函數。
我在問這個,因爲我也想使用這個功能。
對於Magento,我仍然很陌生,我在想如何Magento檢查用戶是否登錄magento/index.php/sales/order/view/order_id/102/
頁面。magento如何檢查用戶是否已登錄訂購頁面
例如,如果與此訂單無關的用戶嘗試去那裏,他將被重定向到他自己的訂單歷史記錄頁面。但是我無法在info.php和sales/order目錄(模板和塊)中的info.phtml中看到這個函數。
我在問這個,因爲我也想使用這個功能。
驗證在控制器中完成。負責訂單詳細信息頁面的控制器是Mage_Sales_OrderController
,它擴展了Mage_Sales_Controller_Abstract
。而在Mage_Sales_Controller_Abstract
有這種方法_canViewOrder
來檢查,如果訂單有明顯的狀態,若訂單客戶相同的客戶登錄
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;
}
//just call this helper function
$isLoggedIn = $this->helper('customer')->isLoggedIn();
非常感謝它似乎是真的該功能,但是你知道它叫什麼嗎?在'OrderController'中,似乎沒有viewAction函數。 – Exia0890
查看父類。 'Mage_Sales_Controller_Abstract'。在那裏應該有一個viewAction調用'_loadValidOrder'調用'_canViewOrder' – Marius
謝謝,它的確在抽象類中。 – Exia0890