我正在自定义 Woocommerce 中的“查看订单”(order-details.php)页面,在“我的帐户”中(当用户登录时),我们有以下代码来打印帐单和送货地址:
<?php if (!$order->get_formatted_billing_address()) _e( 'N/A', 'woocommerce' ); else echo $order->get_formatted_billing_address(); ?>
我想知道是否有办法自定义该输出的每个项目。例如:在我的账户首页,以这种方式显示客户的帐单和收货地址:
<?php
$address = apply_filters( 'woocommerce_my_account_my_address_formatted_address', array(
'first_name' => ucwords(get_user_meta( $customer_id, $name . '_first_name', true )),
'last_name' => ucwords(get_user_meta( $customer_id, $name . '_last_name', true )),
'company' => ucwords(get_user_meta( $customer_id, $name . '_company', true )),
'address_1' => ucwords(get_user_meta( $customer_id, $name . '_address_1', true )),
'address_2' => ucwords(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 );
$formatted_address = $woocommerce->countries->get_formatted_address( $address );
if ( ! $formatted_address )
_e( 'You have not set up this type of address yet.', 'woocommerce' );
else
echo $formatted_address;
?>
就像我想在订单视图页面中使用的那样。我怎么能把“apply_filters”放在这段代码中?