如何在woocommerce的帐户页面上显示结算电话?

时间:2015-06-25 20:01:58

标签: wordpress woocommerce

如何在我的帐户页面([woocommerce_my_account])上显示用户woocommerce帐单电话号码,还可以在编辑地址/送货/页面上进行编辑?我正在编辑my-address.php文件。

        <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 ),
                'billing_phone'    => get_user_meta( $customer_id, $name . '_billing_phone', true ),
                'country'     => get_user_meta( $customer_id, $name . '_country', true )
            ), $customer_id, $name );

            $formatted_address = WC()->countries->get_formatted_address( $address );

            if ( ! $formatted_address )
                _e( 'You have not set up this type of address yet.', 'mk_framework' );
            else
                echo $formatted_address;
        ?>

    </address>

2 个答案:

答案 0 :(得分:0)

您无法在woocommerce中显示电话号码。为此,您必须使用此here中的操作将字段添加到注册中。

然后在您的帐户页面上,在您要显示电话号码的任何位置添加以下内容。

&#39;电话&#39; =&GT; get_user_meta($ customer_id,$ name。&#39; _phone&#39;,true),

答案 1 :(得分:0)

当你像这样使用它时会拉出实际的字段:

'billing_phone' => get_user_meta( $customer_id, $name . '_phone', true ),
'billing_email' => get_user_meta( $customer_id, $name . '_email', true )