• Resolved heyluce

    (@heyluce)


    Hi,

    i want to add a second static field to my csv export. I found on the documentation site this code which works perfectly.

    function custom_woo_ce_order_fields( $fields ) {
    
    	$fields[] = array(
    		'name' => 'static_field',
    		'label' => __( 'Customer ID', 'woo_ce' )
    	);
    	return $fields;
    
    }
    add_filter( 'woo_ce_order_fields', 'custom_woo_ce_order_fields' );
    
    function custom_woo_ce_order( $order, $order_id ) {
    
    	$order->static_field = 'AQU';
    	return $order;
    
    }
    add_filter( 'woo_ce_order', 'custom_woo_ce_order', 10, 2 );

    now i want to add a second static field with the name “AQU1”. I just copied it and renamed the functions, but it is not appearing. could you please help me out with this?

    The second issue is, i changed the date format to “d_m_Y”.

    but my exported filename still shows this format: 2016_06_07

    Thanks a lot!

    https://ww.wp.xz.cn/plugins/woocommerce-exporter/

Viewing 1 replies (of 1 total)
  • Hi heyluce, I’ll answer here and close your Premium Support topic so others can see the answer. 🙂

    I’m not an expert at using markup here on w.org so it might take a few attempts…

    Notice below that within custom_woo_ce_order_fields() the ‘name’ attribute of the $fields array items are unique (e.g. static_field_1, static_field_2), you need to reference these unique field names within custom_woo_ce_order(). Does this help?


    function custom_woo_ce_order_fields( $fields ) {

    $fields[] = array(
    'name' => 'static_field_1',
    'label' => __( 'Customer ID', 'woo_ce' )
    );
    $fields[] = array(
    'name' => 'static_field_2',
    'label' => __( 'Customer Mail Preference', 'woo_ce' )
    );
    return $fields;

    }
    add_filter( 'woo_ce_order_fields', 'custom_woo_ce_order_fields' );

    function custom_woo_ce_order( $order, $order_id ) {

    $order->static_field_1 = 'ID12345';
    $order->static_field_2 = 'SMS only please';
    return $order;

    }
    add_filter( 'woo_ce_order', 'custom_woo_ce_order', 10, 2 );

    Regarding your date formatting issue can you please open a new topic and incldue details here:

    https://ww.wp.xz.cn/support/topic/important-read-this-before-posting-5?replies=1

Viewing 1 replies (of 1 total)

The topic ‘Second custom static field date format’ is closed to new replies.