Hooks/Filters
Each column can be modified by filter before output.
Hook names depend on type of field and field name
- for order – woe_get_order_value_FIELD
- for product – woe_get_order_product_value_FIELD
- for coupon – woe_get_order_coupon_value_FIELD
Use section “Setup fields” to find FIELD – hover the field(see tooltip on the screenshot) OR switch to “JSON” format
EACH type has own parameters
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
//Order: we use usermeta field to fill First Name add_filter('woe_get_order_value_first_name',function( $value,$order, $fieldname ) { $user_id = $order->get_user_id(); return get_user_meta($user_id, 'first_name', true); }, 10, 3 ); // Product: format weight, 0.2->0.200 and 0.12->0.120 add_filter('woe_get_order_product_value_weight', function ($value, $order, $item, $product,$item_meta) { return number_format($value,3,'.',''); }, 10, 5); // Coupon: add prefix to code add_filter('woe_get_order_coupon_value_code', function ($value, $order, $item) { return "WC-".$value; }, 10, 3); |
It’s possible to skip order using filter woe_order_export_started
1 2 3 4 5 |
// export only orders with total > 10 add_filter( 'woe_order_export_started', function ( $order_id ) { $order = new WC_Order($order_id); return ($order->get_total() > 10.00) ? $order_id: false; }); |
There are extra filters to format final text before output woe_xls_output_filter, woe_csv_output_filter, woe_xml_output_filter, woe_json_output_filter
1 2 3 4 5 6 7 8 |
Example: we add namespace "ns2:" to all tags add_filter( 'woe_xml_output_filter', function( $xml, $rec ) { // for <test> $xml = preg_replace( '/(?<=\<)([^\/].*?)(?=\>)/', 'ns2:$1', $xml); // for </test> $xml = preg_replace( '/(?<=\<\/)(.*?)(?=\>)/', 'ns2:$1', $xml); return $xml; } , 10, 2); |