Kar*_*ren 2 wordpress woocommerce
我正在使用Woocommerce在我的Wordpress网站上销售数字下载.我已经能够使用插件来自定义结帐页面,这样客户只需提供他们的姓名和电子邮件地址即可购买产品.我希望在" 客户信息"页面和" 编辑我的地址"页面和" 帐户"页面上显示相同的内容.
现在位于帐户页面的底部,它是从my-address.php页面调用信息.它会显示结算地址(姓名和送货地址),但不会显示,因为他们没有被要求输入送货地址.
我希望结算地址为"姓名",发货地址为"电子邮件",并且可以从中调用此人的电子邮件地址my-address.php.我实际上知道如何将帐单地址更改为名称.但我无法弄清楚如何将发货地址更改为电子邮件并显示此人的电子邮件.
有谁知道我怎么能做到这一点?
谢谢你的时间.
如果将模板文件从插件目录复制到主题(或子主题)目录,则可以编辑它们以获得所需内容.主题目录中的文件将覆盖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 );
Run Code Online (Sandbox Code Playgroud)
该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 );
Run Code Online (Sandbox Code Playgroud)
$name被替换为'billing',所以'_email'如果你愿意,你可以改变其中一个地址行.
| 归档时间: |
|
| 查看次数: |
24098 次 |
| 最近记录: |