WC_Product_CSV_Exporter::prepare_meta_for_export
Export meta data.
Method of the class: WC_Product_CSV_Exporter{}
Hooks from the method
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->prepare_meta_for_export( $product, $row );
- $product(WC_Product) (required)
- Product being exported.
- $row(array) (required) (passed by reference — &)
- Row data.
Changelog
| Since 3.1.0 | Introduced. |
WC_Product_CSV_Exporter::prepare_meta_for_export() WC Product CSV Exporter::prepare meta for export code WC 10.6.2
protected function prepare_meta_for_export( $product, &$row ) {
if ( $this->enable_meta_export ) {
$meta_data = $product->get_meta_data();
if ( count( $meta_data ) ) {
$meta_keys_to_skip = apply_filters( 'woocommerce_product_export_skip_meta_keys', array(), $product );
$i = 1;
foreach ( $meta_data as $meta ) {
if ( in_array( $meta->key, $meta_keys_to_skip, true ) ) {
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 );
/* translators: %s: meta data name */
$this->column_names[ $column_key ] = sprintf( __( 'Meta: %s', 'woocommerce' ), $meta->key );
$row[ $column_key ] = $meta_value;
++$i;
}
}
}
}