Merge branch 'pr/17452'

This commit is contained in:
Mike Jolley 2017-10-30 12:15:41 +00:00
commit b436ad34e6
1 changed files with 13 additions and 5 deletions

View File

@ -525,8 +525,8 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
* Export meta data. * Export meta data.
* *
* @since 3.1.0 * @since 3.1.0
* @param WC_Product $product * @param WC_Product $product Product being exported.
* @param array $row * @param array $row Row data.
*/ */
protected function prepare_meta_for_export( $product, &$row ) { protected function prepare_meta_for_export( $product, &$row ) {
if ( $this->enable_meta_export ) { if ( $this->enable_meta_export ) {
@ -537,13 +537,21 @@ class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
$i = 1; $i = 1;
foreach ( $meta_data as $meta ) { foreach ( $meta_data as $meta ) {
if ( ! is_scalar( $meta->value ) || in_array( $meta->key, $meta_keys_to_skip ) ) { if ( in_array( $meta->key, $meta_keys_to_skip, true ) ) {
continue; continue;
} }
// Allow 3rd parties to process the meta, e.g. to transform non-scalar values to scalar.
$meta_value = apply_filters( 'woocommerce_product_export_meta_value', $meta->value, $meta, $product, $row );
if ( ! is_scalar( $meta_value ) ) {
continue;
}
$column_key = 'meta:' . esc_attr( $meta->key ); $column_key = 'meta:' . esc_attr( $meta->key );
$this->column_names[ $column_key ] = sprintf( __( 'Meta: %s', 'woocommerce' ), $meta->key ); $this->column_names[ $column_key ] = sprintf( __( 'Meta: %s', 'woocommerce' ), $meta->key );
$row[ $column_key ] = $meta->value; $row[ $column_key ] = $meta_value;
$i++; $i ++;
} }
} }
} }