wc_get_email_order_items()WC 3.0.0

Get HTML for the order items to be shown in emails.

Return

String.

Usage

wc_get_email_order_items( $order, $args );
$order(WC_Order) (required)
Order object.
$args(array)
Arguments.
Default: array()

Changelog

Since 3.0.0 Introduced.

wc_get_email_order_items() code WC 9.3.1

function wc_get_email_order_items( $order, $args = array() ) {
	ob_start();

	$defaults = array(
		'show_sku'      => false,
		'show_image'    => false,
		'image_size'    => array( 32, 32 ),
		'plain_text'    => false,
		'sent_to_admin' => false,
	);

	$args     = wp_parse_args( $args, $defaults );
	$template = $args['plain_text'] ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';

	wc_get_template(
		$template,
		apply_filters(
			'woocommerce_email_order_items_args',
			array(
				'order'               => $order,
				'items'               => $order->get_items(),
				'show_download_links' => $order->is_download_permitted() && ! $args['sent_to_admin'],
				'show_sku'            => $args['show_sku'],
				'show_purchase_note'  => $order->is_paid() && ! $args['sent_to_admin'],
				'show_image'          => $args['show_image'],
				'image_size'          => $args['image_size'],
				'plain_text'          => $args['plain_text'],
				'sent_to_admin'       => $args['sent_to_admin'],
			)
		)
	);

	return apply_filters( 'woocommerce_email_order_items_table', ob_get_clean(), $order );
}