简体   繁体   English

更改 WooCommerce 订单中管理员帐单地址字段的顺序

[英]Change the order of admin billing address fields in WooCommerce orders

I have problem with woocommerce order in admin I want the billing_address_2 show at the end of the page as exmple bellow.我在管理中遇到 woocommerce 订单问题我希望 billing_address_2 显示在页面末尾,如下所示。

can any one please help me.谁能帮帮我吗。

在此处输入图片说明

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.

相关问题 将自定义帐单数据添加到 Woocommerce 管理订单中的帐单格式地址 - Add custom billing data to billing formatted address in Woocommerce admin orders Magento onestepcheckout更改帐单地址字段顺序 - Magento onestepcheckout change billing address fields order 在帐单地址后显示 WooCommerce 管理订单中的自定义元数据 - Display custom meta data in WooCommerce admin order after billing address 在 Woocommerce 中删除管理员添加订单的国家/地区计费和运输字段 - Remove country billing and shipping fields on admin add order in Woocommerce 在订单电子邮件 woocommerce 的帐单地址和送货地址中添加新添加的字段 - Adding newly added fields in billing address and shipping address in order emails woocommerce 在WooCommerce订单管理员中搜索自定义字段 - Search WooCommerce orders admin for custom fields 如何在 WooCommerce 管理员单笔订单中显示自定义结帐计费字段 - How to display custom checkout billing field in WooCommerce admin single orders 在帐单地址 woocommerce 处添加新字段 - Add new fields at the billing address woocommerce 编辑 WooCommerce 结帐页面帐单地址字段 - Editing WooCommerce checkout page billing address fields 如何在订单收到的woocommerce结账页面上更改送货地址和账单地址的文本? - How to change text of shipping address and billing address on order recieved page of woocommerce checkout?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM