WordPress at Your Fingertips
function is not described

WC_Product_CSV_Exporter::prepare_downloads_for_export() protected WC 3.1.0

Export downloads.

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

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->prepare_downloads_for_export( $product, $row );
$product(WC_Product) (required)
Product being exported.
$row(array) (required) (passed by reference — &)
Row being exported.

Changelog

Since 3.1.0 Introduced.

Code of WC_Product_CSV_Exporter::prepare_downloads_for_export() WC 5.9.0

protected function prepare_downloads_for_export( $product, &$row ) {
	if ( $product->is_downloadable() && $this->is_column_exporting( 'downloads' ) ) {
		$downloads = $product->get_downloads( 'edit' );

		if ( $downloads ) {
			$i = 1;
			foreach ( $downloads as $download ) {
				/* translators: %s: download number */
				$this->column_names[ 'downloads:id' . $i ] = sprintf( __( 'Download %d ID', 'woocommerce' ), $i );
				/* translators: %s: download number */
				$this->column_names[ 'downloads:name' . $i ] = sprintf( __( 'Download %d name', 'woocommerce' ), $i );
				/* translators: %s: download number */
				$this->column_names[ 'downloads:url' . $i ] = sprintf( __( 'Download %d URL', 'woocommerce' ), $i );
				$row[ 'downloads:id' . $i ]                 = $download->get_id();
				$row[ 'downloads:name' . $i ]               = $download->get_name();
				$row[ 'downloads:url' . $i ]                = $download->get_file();
				$i++;
			}
		}
	}
}