自定义Woocommerce客户帐户页面

时间:2013-09-08 21:30:33

标签: wordpress woocommerce

我使用Woocommerce在Wordpress网站上销售数字下载。我已经能够使用插件来自定义结帐页面,这样客户只需提供他们的姓名和电子邮件地址即可购买产品。我希望在客户信息页面和编辑我的地址页面和帐户页面上显示相同的内容。

现在,在“帐户”页面的底部,它会从my-address.php页面调用信息。它会显示结算地址(姓名和送货地址),但不会显示,因为他们没有被要求输入送货地址。

我希望结算地址为“姓名”,发货地址为“电子邮件”,并且要从my-address.php调用此人的电子邮件地址。我实际上知道如何将帐单地址更改为名称。但我无法弄清楚如何将发货地址更改为电子邮件并显示此人的电子邮件。

有没有人知道我该怎么做?

感谢您的时间。

1 个答案:

答案 0 :(得分:6)

如果将模板文件从插件目录复制到主题(或子主题)目录,则可以编辑它们以获得所需内容。主题目录中的文件将覆盖stock插件模板。

所以原始模板就在 plugins/woocommerce/templates/myaccount

将您要更改的文件(可能只是my-address.php和/或my-account.php)移至themes/my-theme/woocommerce/templates/myaccount/

(注意:这就是文档所说的,虽然我发现该目录应该是themes/my-theme/woocommerce/myaccount/ - 尽管这可能来自我已安装的冲突插件。)

当您编辑PHP文件时,您所追求的字段是:

$firstname = get_user_meta( $customer_id, 'billing_first_name', true );
$lastname = get_user_meta( $customer_id, 'billing_last_name', true );
$email = get_user_meta( $customer_id, 'billing_email', true );

my-address.php文件有一个类似的数组:

$address = apply_filters( 'woocommerce_my_account_my_address_formatted_address', array(
                'first_name'    => get_user_meta( $customer_id, $name . '_first_name', true ),
                'last_name'     => get_user_meta( $customer_id, $name . '_last_name', true ),
                'company'       => get_user_meta( $customer_id, $name . '_company', true ),
                'address_1'     => get_user_meta( $customer_id, $name . '_address_1', true ),
                'address_2'     => get_user_meta( $customer_id, $name . '_address_2', true ),
                'city'          => get_user_meta( $customer_id, $name . '_city', true ),
                'state'         => get_user_meta( $customer_id, $name . '_state', true ),
                'postcode'      => get_user_meta( $customer_id, $name . '_postcode', true ),
                'country'       => get_user_meta( $customer_id, $name . '_country', true )
            ), $customer_id, $name );

$name被替换为'billing',因此如果您愿意,可以将其中一个地址行更改为'_email'

相关问题