Last active
September 27, 2015 14:59
-
-
Save woogist/59563029616d2866c36f to your computer and use it in GitHub Desktop.
Add product dimension and weight to the order CSV export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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