简体   繁体   English

更新 WooCommerce 管理员运输订单字段

[英]Updating WooCommerce Admin Shipping Order Fields

In functions.php I am trying to use this, but it is not working:在 functions.php 中,我正在尝试使用它,但它不起作用:

function rt_woocommerce_admin_shipping_fields( $fields ) {
    $fields['first_name']['value'] = $_GET['f'];
    $fields['last_name']['value'] = $_GET['l'];
    $fields['address_1']['value'] = $_GET['a'];
    $fields['address_2']['value'] = $_GET['b'];
    // etc
    // etc

    return $fields;
}

add_filter( 'woocommerce_admin_shipping_fields', 'rt_woocommerce_admin_shipping_fields' );

woocommerce_admin_billing_fields() works but the shipping function does not. woocommerce_admin_billing_fields() 有效,但运费 function 无效。 Any advice?有什么建议吗? I need to update the fields with $_GET variables on page load.我需要在页面加载时使用 $_GET 变量更新字段。 This works perfectly for the billing fields.这非常适合计费字段。

The array has label and show indexes for each item in shipping fields.该数组有labelshow运输字段中每个项目的索引。 There is no value index by default.默认没有value索引。 See the woocommerce_admin_shipping_fields filter below.请参阅下面的woocommerce_admin_shipping_fields过滤器。

self::$shipping_fields = apply_filters(
            'woocommerce_admin_shipping_fields',
            array(
                'first_name' => array(
                    'label' => __( 'First name', 'woocommerce' ),
                    'show'  => false,
                ),
                'last_name'  => array(
                    'label' => __( 'Last name', 'woocommerce' ),
                    'show'  => false,
                ),
                'company'    => array(
                    'label' => __( 'Company', 'woocommerce' ),
                    'show'  => false,
                ),
                'address_1'  => array(
                    'label' => __( 'Address line 1', 'woocommerce' ),
                    'show'  => false,
                ),
                'address_2'  => array(
                    'label' => __( 'Address line 2', 'woocommerce' ),
                    'show'  => false,
                ),
                'city'       => array(
                    'label' => __( 'City', 'woocommerce' ),
                    'show'  => false,
                ),
                'postcode'   => array(
                    'label' => __( 'Postcode / ZIP', 'woocommerce' ),
                    'show'  => false,
                ),
                'country'    => array(
                    'label'   => __( 'Country / Region', 'woocommerce' ),
                    'show'    => false,
                    'type'    => 'select',
                    'class'   => 'js_field-country select short',
                    'options' => array( '' => __( 'Select a country / region…', 'woocommerce' ) ) + WC()->countries->get_shipping_countries(),
                ),
                'state'      => array(
                    'label' => __( 'State / County', 'woocommerce' ),
                    'class' => 'js_field-state select short',
                    'show'  => false,
                ),
                'phone'      => array(
                    'label' => __( 'Phone', 'woocommerce' ),
                ),
            )
        );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Woocommerce 中删除管理员添加订单的国家/地区计费和运输字段 - Remove country billing and shipping fields on admin add order in Woocommerce WooCommerce 将订单送货地址作为单独的字段 - WooCommerce get order shipping address as separate fields WooCommerce 管理员创建订单并在订单付款时添加运费 - WooCommerce Admin Create Order & Adding Shipping on Order Pay 在 Woocommerce 的客户运输部分下向管理员用户添加其他字段 - Add additional fields to Admin User under Customer shipping section in Woocommerce 禁止管理员在 WooCommerce 后端编辑订单发货详情 - Disabling the editing of the order shipping details by admin in WooCommerce backend 在Woocommerce管理员中添加新订单时隐藏常规和运输详细信息 - Hide general and shipping details when adding a new order in Woocommerce admin 将运输方式添加到 Woocommerce 订单页面仅适用于管理员 - Adding shipping methods to Woocommerce Order Page for Admin only 从Woocommerce管理员编辑订单页面删除运输行 - Remove shipping row from Woocommerce admin edit order pages 在“按订单付款”页面中显示账单和运输字段 Woocommerce - Display billing and shipping fields in "Pay to order" page Woocommerce 在 Woocommerce 的管理员编辑订单页面上显示每个特定订单的所有可用运输方式 - Display ALL available shipping methods for each specific order on admin edit order pages in Woocommerce
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM