Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tamarazuk/ee6212e703faabefba41 to your computer and use it in GitHub Desktop.
Save tamarazuk/ee6212e703faabefba41 to your computer and use it in GitHub Desktop.
function sv_add_weight_to_csv_export_import_format( $order_data, $order ) {
$count = 1;
// add line items
foreach ( $order->get_items() as $item ) {
$product = $order->get_product_from_item( $item );
if ( ! is_object( $product ) ) {
$product = new WC_Product( 0 );
}
if ( $weight = $product->get_weight() ) {
$order_data[ "order_item_{$count}" ] .= '|weight: ' . $weight;
}
$count++;
}
return $order_data;
}
add_filter( 'wc_customer_order_csv_export_order_row', 'sv_add_weight_to_csv_export_import_format', 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment