Product SKU export
-
Hi Ankit,
Just reposting here a request I made through your web site contact form a few days as I haven’t yet received a reply.
A year or so ago, you sent me the script, below, to export product SKU. It worked perfectly, until recently, when included in the child theme function.php file. Now the product SKU field in the exported csv file just has a hyphen in it instead of the SKU value. Could you please look into this? Perhaps the script needs to be updated to be compatible with WooCommerce version 3.0.6. Also, it would be preferable to have the product SKU as part of the plugin rather than an addition.
Thanks,
David
function wsoe_hook() { add_filter( 'wpg_order_columns', 'wsoe_sku' ); add_filter( 'wc_settings_tab_order_export', 'wsoe_sku_setting' ); add_action( 'wpg_add_values_to_csv', 'wsoe_add_sku', 10, 6 ); } add_action( 'init', 'wsoe_hook', 9 ); function wsoe_sku( $fields ) { $fields['wc_settings_tab_sku'] = __( 'SKU', 'woocommerce-simply-order-export' ); return $fields; } function wsoe_sku_setting( $setting ) { $setting['sku'] = array( 'name' => __( 'SKU', 'woocommerce-simply-order-export' ), 'type' => 'checkbox', 'desc' => __( 'Product SKU', 'woocommerce-simply-order-export' ), 'id' => 'wc_settings_tab_sku' ); return $setting; } function wsoe_add_sku( &$csv_values, $order_details, $key, $fields, $item_id, $current_item ) { switch ( $key ) { case 'wc_settings_tab_sku': if( array_key_exists( 'wc_settings_tab_product_name', $fields ) ) { array_push( $csv_values, get_post_meta( $current_item['product_id'], '_sku', true ) ); }else{ array_push( $csv_values, '-' ); } break; default : break; } }
- The topic ‘Product SKU export’ is closed to new replies.