Skip to content

Instantly share code, notes, and snippets.

@woogist
Last active September 27, 2015 14:59
Show Gist options
  • Save woogist/59563029616d2866c36f to your computer and use it in GitHub Desktop.
Save woogist/59563029616d2866c36f to your computer and use it in GitHub Desktop.
Add product dimension and weight to the order CSV export
/**
* Add weight as line item meta in CSV export
*/
function sv_add_weight_to_csv_export_line_item( $line_item, $item, $product, $order ) {
if ( $product->get_weight() ) {
$line_item['weight'] = $product->get_weight() . ' ' . get_option( 'woocommerce_weight_unit' );
}
if ( $product->length ) {
$line_item['length'] = $product->length . ' ' . get_option( 'woocommerce_dimension_unit' );
}
if ( $product->width ) {
$line_item['width'] = $product->width . ' ' . get_option( 'woocommerce_dimension_unit' );
}
if ( $product->height ) {
$line_item['height'] = $product->height . ' ' . get_option( 'woocommerce_dimension_unit' );
}
return $line_item;
}
add_filter( 'wc_customer_order_csv_export_order_line_item', 'sv_add_weight_to_csv_export_line_item', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment