【问题标题】:Magento call customer first name in specific cms pageMagento 在特定的 cms 页面中呼叫客户的名字
【发布时间】:2012-10-02 23:13:36
【问题描述】:

我正在尝试在一个页面上称呼客户的名字。该页面已仅限于登录会员。因此,如果您尝试访问该页面并且您还没有登录,您将被重定向到登录页面。

如何在一个特定的 CMS 页面上呼叫、回显或显示已登录客户的名字?

我是一个尝试学习 magento 的菜鸟。非常感谢任何帮助。

【问题讨论】:

    标签: magento variables echo


    【解决方案1】:

    Magento 客户名字登录用户

    $session = Mage::getSingleton('customer/session');
    
    if($session->isLoggedIn())
    {
        $customer = $session->getCustomer();
        echo $customer->getFirstname();
    }
    

    尝试实现上述代码以在您的 CMS 页面上显示客户名字。

    【讨论】:

      【解决方案2】:

      在 .phtml 文件中获取客户名称

         echo Mage::helper('customer')->getCustomerName();
      

      阅读更多@Current user in Magento?

      要在 cms 页面中获取客户名称,我会使用从 cms 页面调用 phtml 文件

       {{block type="core/template" template="path/to/file/customer_name.phtml"}}
      

      阅读更多@how to call a PHTML file within a CMS page Magento

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-10
        • 1970-01-01
        • 2021-06-16
        • 2014-12-07
        • 1970-01-01
        • 2015-04-19
        相关资源
        最近更新 更多