Advanced Order Export For WooCommerce 這支外掛非常好用,他可以幫你把要輸出的欄位,對應好輸出成excel及csv等格式,其中還有一個很強桿的功能,支援php輸出,支援php輸出基本上就可以處理各種疑難雜症的欄位,此功能在 Misc settings 勾選 Custom PHP code to modify output
使用前可先參考官方的介紹案例 :
https://docs.algolplus.com/algol_order_export/hooks-filters/
舉例,訂單編號前面加英文GG
add_filter('woe_get_order_value_custom_num',function ($value, $order,$fieldname) { $value = 'GG' .$order->get_order_number(); return $value; },10,3);
溫層的欄位值修改,客制欄位 additional_temp,以宅急便溫層為案例
add_filter('woe_get_order_value_custom_temp', function ($value, $order, $fieldname) { $additional_temp_value = get_post_meta($order->get_id(), 'additional_temp', true); if ($additional_temp_value === '冷凍') { return '0'; } else { return '1'; } }, 10, 3); add_filter('woe_get_order_value_custom_additional_receitp_id', function ($value, $order, $fieldname) { $additional_receitp_id_value = get_post_meta($order->get_id(), 'additional_receitp_id', true); if (empty($additional_receitp_id_value)) { return '1'; } else { return '0'; } }, 10, 3);
訂購人姓名連在一起
add_filter('woe_get_order_value_custom_name1',function ($value, $order,$fieldname) { $value = $order->get_billing_last_name(). '' .$order->get_billing_first_name(); return $value; },10,3);
之前都是透過EXCEL置換公式,這要需要多一個工,2023年開始有了ChatGPT協助寫程式,用這招會更方便