WC_Emails::order_downloadspublicWC 3.2.0

Show order downloads in a table.

Method of the class: WC_Emails{}

Hooks from the method

Returns

null. Nothing (null).

Usage

$WC_Emails = new WC_Emails();
$WC_Emails->order_downloads( $order, $sent_to_admin, $plain_text, $email );
$order(WC_Order) (required)
Order instance.
$sent_to_admin(true|false)
If should sent to admin.
Default: false
$plain_text(true|false)
If is plain text email.
Default: false
$email(string)
Email address.
Default: ''

Changelog

Since 3.2.0 Introduced.

WC_Emails::order_downloads() code WC 10.5.0

public function order_downloads( $order, $sent_to_admin = false, $plain_text = false, $email = '' ) {
	$show_downloads = $order->has_downloadable_item() && $order->is_download_permitted() && ! $sent_to_admin && ! is_a( $email, 'WC_Email_Customer_Refunded_Order' );

	if ( ! $show_downloads ) {
		return;
	}

	$downloads = $order->get_downloadable_items();

	/**
	 * Filter the columns of the order downloads table.
	 *
	 * @since 3.2.0
	 * @since 10.0.0 Added $order parameter.
	 * @param array    $columns Array of columns.
	 * @param WC_Order $order  Order object.
	 */
	$columns = apply_filters(
		'woocommerce_email_downloads_columns',
		array(
			'download-product' => __( 'Product', 'woocommerce' ),
			'download-expires' => __( 'Expires', 'woocommerce' ),
			'download-file'    => __( 'Download', 'woocommerce' ),
		),
		$order
	);

	if ( $plain_text ) {
		wc_get_template(
			'emails/plain/email-downloads.php',
			array(
				'order'         => $order,
				'sent_to_admin' => $sent_to_admin,
				'plain_text'    => $plain_text,
				'email'         => $email,
				'downloads'     => $downloads,
				'columns'       => $columns,
			)
		);
	} else {
		wc_get_template(
			'emails/email-downloads.php',
			array(
				'order'         => $order,
				'sent_to_admin' => $sent_to_admin,
				'plain_text'    => $plain_text,
				'email'         => $email,
				'downloads'     => $downloads,
				'columns'       => $columns,
			)
		);
	}
}