dqk94069 2019-03-27 00:08
浏览 186
已采纳

将自定义结算数据添加到Woocommerce管理订单中的结算格式地址

With Woocommerce, I would like see user meta data in admin order edit pages using woocommerce_localisation_address_formats hook.

Based on "Woocommerce Edit order on admin dashboard" answer code, that I have lightly changed as follow:

add_filter( 'woocommerce_localisation_address_formats', 'admin_localisation_address_formats', 50, 1 );
function admin_localisation_address_formats( $address_formats ){
    if( is_admin() ){
        $address_formats = array();

        $countries = array('default', 'AU', 'AT', 'BE', 'CA', 'CH', 'CL', 'CN', 'CZ',
        'DE', 'EE', 'FI', 'DK', 'FR', 'HK', 'HU', 'IN', 'IS', 'IT', 'JP', 'TW', 'LI',
        'NL', 'NZ', 'NO', 'PL', 'PT', 'SK', 'SI', 'ES', 'SE', 'TR', 'US', 'VN' );

        foreach( $countries as $country_code ) {
            $address_formats[$country_code] = "{company}
{name}
{address_1} {address_2} {postcode}
{city} {state}
{country}
{billing_nombrecontacto}";
        }
    }
    return $address_formats;
}

Where {billing_nombrecontacto} should be custom data to insert in admin order pages… But it doesn't make anything.

To add a billing_nombrecontacto I have used the following code:

add_filter('woocommerce_billing_fields', 'custom_woocommerce_billing_fields');
function custom_woocommerce_billing_fields($fields,$fields2)
{
    $fields['billing_nombrecontacto'] = array(
        'label' => __('Nombre de contacto', 'woocommerce'), // Add custom field label
        'placeholder' => _x('Nombre de contacto', 'placeholder', 'woocommerce'), // Add custom field placeholder
        'required' => false, // if field is required or not
        'clear' => false, // add clear or not
        'type' => 'text', // add field type
        'class' => array('my-css')    // add class name

    );

    $fields['billing_cuit'] = array(
        'label' => __('CUIT', 'woocommerce'), // Add custom field label
        'placeholder' => _x('CUIT', 'placeholder', 'woocommerce'), // Add custom field placeholder
        'required' => false, // if field is required or not
        'clear' => false, // add clear or not
        'type' => 'text', // add field type
        'class' => array('my-css')    // add class name

    );

    $fields['billing_emaildelvendedor'] = array(
        'label' => __('Email del Contacto', 'woocommerce'), // Add custom field label
        'placeholder' => _x('email del Vendedor', 'placeholder', 'woocommerce'), // Add custom field placeholder
        'required' => false, // if field is required or not
        'clear' => false, // add clear or not
        'type' => 'text', // add field type
        'class' => array('my-css')    // add class name

    );

    $fields['billing_nombrecontacto']['priority'] = 102;

    return  $fields;
}

The data is collected correctly, I can see it in my account for this custom field.

How to make it work? I am stuck.

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 有关c++的问题,利用相关知识
      • ¥15 求香农编码和解码的matlab代码
      • ¥20 ROS中的TEB局部规划问题
      • ¥20 关于#matlab#的问题:要求测出上面图片中所有同心圆的半径
      • ¥20 epanet软件运行问题
      • ¥15 Python 文件读取
      • ¥60 dpabi进行Alff计算时脑池有干扰信号
      • ¥15 利用kmeans或kshape聚类分析对归一化的无量纲时间-降雨序列进行聚类
      • ¥15 protel99.SE提示一下弹窗
      • ¥15 银河麒麟v10 执行.run失败如何解决