2

I am selling digital downloads on my Wordpress site using Woocommerce. I have been able to use a plugin to customize the checkout page so that customers only have to give their first and last names and email address to purchase a product. I would like the same thing to show on the Customer Information page and Edit My Address page and Account page.

Right now at the bottom of the Account page, it's calling information from the my-address.php page. It calls Billing Address (First and Last Name) and Shipping Address, which doesn't show up because they have not been required to enter a shipping address.

I would like the Billing Address to be "Name" and the Shipping Address to be "Email" and to have the person's email address to be called from my-address.php. I actually know how to change the Billing Address to Name. But I can't figure out how to change Shipping Address to Email and to have the person's email show up.

Does anyone have a clue how I could do this?

Thanks for your time.

4

1 回答 1

6

如果您将模板文件从插件目录复制到您的主题(或子主题)目录,您可以编辑它们以获得您想要的。主题目录中的文件将覆盖股票插件模板。

所以原始模板在 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'

于 2013-12-17T23:01:34.057 回答