Reputation: 77
I have problem with woocommerce order in admin I want the billing_address_2 show at the end of the page as exmple bellow.
can any one please help me.
Upvotes: 1
Views: 1894
Reputation: 253886
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
.
The only available and efficient hook is: 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.
Addition - Showing the billing_address_2
field before billing_country
field:
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;
}
Upvotes: 1