Magento:如何在客户信息字段上显示客户的电话号码 [英] Magento: How to display customer's phone number on customer information field
问题描述
我正在尝试在客户帐户信息部分下显示客户的电话号码.我知道电话号码属于客户地址部分,但我正在尝试重新设计客户帐户信息的外观.
I’m trying to have the customer’s phone number show under the customer account information section. I know the phone number belongs to the customer address section but I’m trying to redesign how the customer account information looks like.
我为客户ID添加了一个新的自定义字段,由于客户ID属于customer_entity,因此可以使用以下代码显示该字段.
I added a new custom field for Customer ID and I’m able to display it by using the following code as the customer ID belongs to customer_entity.
<?php echo $this->__('Identification:') ?><?php echo $this->htmlEscape($this->getCustomer()->getCustid()) ?>
但是现在我正尝试使用此方法对电话号码进行同样的操作
but now I’m trying to do the same for the telephone number by using this
<?php echo $this->__('Telephone:') ?><?php echo $this->htmlEscape($this->getCustomer()->getTelephone()) ?>
但是它不显示任何数据,因为它属于customer_address_entity,我相信应该是
But it doesn’t display any data since it belongs to customer_address_entity and I BELIEVE it should be
->getAddress()->getTelephone()
代替
->getCustomer()->getTelephone()
但是使用-> getAddress只会给我一个错误在非对象上调用成员函数getTelephone()"
but using ->getAddress just gives me an error " Call to a member function getTelephone() on a non-object "
有人知道怎么做吗?
作为参考,我正在尝试将此数据显示在文件customer \ account \ dashboard \ info.phtml
As a reference, I'm trying to have this data display on the file customer\account\dashboard\info.phtml
谢谢.
推荐答案
哦,谢谢,我现在发表! (请参阅原始帖子下的评论.)
Oh, thanks I'll post now! (see comments under original post).
只需使用以下内容:
$this->getCustomer()->getPrimaryBillingAddress()->getTelephone();
第一部分将为您提供所有详细信息,然后您可以根据@paperids使用var_dump()
进行探索.
The first part will give you all the details, which you could then explore with var_dump()
as per @paperids.
这篇关于Magento:如何在客户信息字段上显示客户的电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!