Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Ankit

    I am trying to add a Product Category to the export file.

    The result is Product Category appearing on the Order Export page, the title appearing on the Excel sheet, but the column being blank.

    Do you have any advice? This is my attempt:

    function wpg_add_columns($cols) {
    
    $cols['wc_settings_tab_product_cat'] = __('Product Category', 'mytheme');
    return $cols;
    }
    add_filter('wpg_order_columns', 'wpg_add_columns');
    
    function wpg_add_fields($settings) {
    
    $settings['product_cat'] = array(
    'name' => __( 'Product Category', 'woocommerce-simply-order-export' ),
    'type' => 'checkbox',
    'desc' => __( 'Product Category', 'woocommerce-simply-order-export' ),
    'id' => 'wc_settings_tab_product_cat'
    );
    
    return $settings;
    
    }
    add_filter('wc_settings_tab_order_export', 'wpg_add_fields');
    
    function csv_write( &$csv, $od, $fields ) {
    
    if( !empty( $fields['wc_settings_tab_product_cat'] ) && $fields['wc_settings_tab_product_cat'] === true ){
    array_push( $csv, strip_tags($od->get_product_cat()) );
    }
    
    }
    add_action('wpg_before_csv_write', 'csv_write', 10, 3);

    Hi Ankit

    I am trying to add a Product Category to the export file.

    The result is Product Category appearing on the Order Export page, the title appearing on the Excel sheet, but the column being blank.

    Do you have any advice? This is my attempt:

    function wpg_add_columns($cols) {

    $cols[‘wc_settings_tab_product_cat’] = __(‘Product Category’, ‘mytheme’);
    return $cols;
    }
    add_filter(‘wpg_order_columns’, ‘wpg_add_columns’);

    function wpg_add_fields($settings) {

    $settings[‘product_cat’] = array(
    ‘name’ => __( ‘Product Category’, ‘woocommerce-simply-order-export’ ),
    ‘type’ => ‘checkbox’,
    ‘desc’ => __( ‘Product Category’, ‘woocommerce-simply-order-export’ ),
    ‘id’ => ‘wc_settings_tab_product_cat’
    );

    return $settings;

    }
    add_filter(‘wc_settings_tab_order_export’, ‘wpg_add_fields’);

    function csv_write( &$csv, $od, $fields ) {

    if( !empty( $fields[‘wc_settings_tab_product_cat’] ) && $fields[‘wc_settings_tab_product_cat’] === true ){
    array_push( $csv, strip_tags($od->get_product_cat()) );
    }

    }
    add_action(‘wpg_before_csv_write’, ‘csv_write’, 10, 3);

Viewing 2 replies - 1 through 2 (of 2 total)