![](/img/trans.png)
[英]Add custom billing data to billing formatted address in Woocommerce admin orders
[英]Change the order of admin billing address fields in WooCommerce orders
負責顯示這些字段的核心文件位於 WooCommerce 插件中: includes/admin/meta-boxes/class-wc-meta-box-order-data.php
。
唯一可用且有效的鈎子是: woocommerce_admin_shipping_fields
。
但是您只能使用以下內容更改管理計費字段順序:
add_filter( 'woocommerce_admin_billing_fields' , 'change_order_admin_billing_fields' );
function change_order_admin_billing_fields( $fields ) {
global $the_order;
$address_2 = $fields['address_2'];
unset($fields['address_2']);
$fields['address_2'] = $address_2;
return $fields;
}
這會給你類似的東西:
因此,如您所見,您不會根據需要在交易 ID 之后顯示帳單地址address_2
字段,而只會在帳單phone
字段下顯示。
添加 - 在billing_address_2
字段之前顯示billing_country
字段:
add_filter( 'woocommerce_admin_billing_fields' , 'change_order_admin_billing_fields' );
function change_order_admin_billing_fields( $fields ) {
global $the_order;
$sorted_fields = [];
$address_2 = $fields['address_2'];
unset($fields['address_2']);
foreach ( $fields as $key => $values ) {
if( $key === 'country' ) {
$sorted_fields['address_2'] = $address_2;
}
$sorted_fields[$key] = $values;
}
return $sorted_fields;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.