add product_cat meta key
-
Hello,
I tried to add the product category field by editing the plugin. I’ve used the meta key product_cat. This field has been added to settings but doesn’t come out in the csv file.
this is the code I’ve added to the function.php. am i doing something wrong? can you help?
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 ){
$product_cat = get_post_meta( $od->id, ‘_product_cat_title’, true );
array_push( $csv, $product_cat );
}}
add_action(‘wpg_before_csv_write’, ‘csv_write’, 10, 3);
- The topic ‘add product_cat meta key’ is closed to new replies.