du31992 2016-03-08 13:35 采纳率: 0%
浏览 96
已采纳

WooCommerce组合字段用于CSV订单导出

I am using WooCommerce Customer/Order CSV Export plugin and would like to use a code snippet in my themes functions.php to create the required CSV format. The next code snippet fills the new columns with data, but I want to combine some of the WooCommerce checkout fields together in column 4, but how do I do that? The outlined code is not working..

function wc_csv_export_modify_row_data( $order_data, $order, $csv_generator ) {

$custom_data = array(
    'column_1' => '2',
    'column_2' => '302115',
    'column_3' => '[Klant]',
    'column_4' => get_post_meta( $order->id, '_shipping_first_name', true ),
    /*'column_4' => $order_data['_shipping_first_name'].''.['_shipping_last_name'].'¶'.
                    $order_data['_shipping_address_1'].'¶'.
                    $order_data['_shipping_address_2'].'¶'.''.'¶'.
                    $order_data['_shipping_postcode'].'¶'.
                    $order_data['_shipping_city'].'¶'.
                    $order_data['_shipping_country'].'¶'.
                    $order_data['_billing_email'].'¶'.
                    $order_data['_shipping_company'],*/
    'column_5' => 'SEL'
);
  • 写回答

1条回答 默认 最新

  • dongyin2643 2016-03-15 18:24
    关注

    I needed to do this as well for some of our order exports. Here's how I did it -

    $custom_data = array(
        // combine first name and last name to 1 field
        'Ship_to_Name' => get_post_meta( $order->id, '_shipping_first_name', true )." ".get_post_meta( $order->id, '_shipping_last_name', true ),
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题