WordPress at Your Fingertips
function is not described

WC_Product_CSV_Exporter::prepare_meta_for_export() protected WC 3.1.0

Export meta data.

{} It's a method of the class: WC_Product_CSV_Exporter{}

Return

null. Nothing.

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.

Code of WC_Product_CSV_Exporter::prepare_meta_for_export() WC 5.9.0

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 ++;
			}
		}
	}
}