[英]Change the order of admin billing address fields in WooCommerce orders
The core file that is responsible to displayinng that fields is located in WooCommerce plugin under: includes/admin/meta-boxes/class-wc-meta-box-order-data.php
.负责显示这些字段的核心文件位于 WooCommerce 插件中:
includes/admin/meta-boxes/class-wc-meta-box-order-data.php
。
The only available and efficient hook is: woocommerce_admin_shipping_fields
.唯一可用且有效的钩子是:
woocommerce_admin_shipping_fields
。
But you will only be able to change the admin billing fields order using something like:但是您只能使用以下内容更改管理计费字段顺序:
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;
}
Which will give you something like:这会给你类似的东西:
So as you can see you will not get the billing address_2
field to be displayed after the transaction ID as you wish, but only under the billing phone
field.因此,如您所见,您不会根据需要在交易 ID 之后显示帐单地址
address_2
字段,而只会在帐单phone
字段下显示。
Addition - Showing the billing_address_2
field before billing_country
field :添加 - 在
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.