Automattic\WooCommerce\Blocks\BlockTypes\OrderConfirmation

Totals::render_order_details_table_item()protectedWC 1.0

Render an item in the order details table.

Method of the class: Totals{}

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->render_order_details_table_item( $order, $item_id, $item, $product );
$order(\WC_Order) (required)
Order object.
$item_id(int) (required)
Item ID.
$item(\WC_Order_Item) (required)
Item object.
$product(\WC_Product|false) (required)
Product object if it exists.

Totals::render_order_details_table_item() code WC 8.7.0

protected function render_order_details_table_item( $order, $item_id, $item, $product ) {
	$is_visible = $product && $product->is_visible();
	// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
	$row_class = apply_filters( 'woocommerce_order_item_class', 'woocommerce-table__line-item order_item', $item, $order );
	// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
	$product_permalink = apply_filters( 'woocommerce_order_item_permalink', $is_visible ? $product->get_permalink( $item ) : '', $item, $order );

	// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
	$item_name    = apply_filters(
		'woocommerce_order_item_name',
		$product_permalink ? sprintf( '<a href="%s">%s</a>', $product_permalink, $item->get_name() ) : $item->get_name(),
		$item,
		$is_visible
	);
	$qty          = $item->get_quantity();
	$refunded_qty = $order->get_qty_refunded_for_item( $item_id );
	$qty_display  = $refunded_qty ? '<del>' . esc_html( $qty ) . '</del> <ins>' . esc_html( $qty - ( $refunded_qty * -1 ) ) . '</ins>' : esc_html( $qty );
	// phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
	$item_qty = apply_filters(
		'woocommerce_order_item_quantity_html',
		'<strong class="product-quantity">' . sprintf( '&times;&nbsp;%s', $qty_display ) . '</strong>',
		$item
	);

	return '
		<tr class="' . esc_attr( $row_class ) . '">
			<td class="wc-block-order-confirmation-totals__product">
				' . wp_kses_post( $item_name ) . '&nbsp;
				' . wp_kses_post( $item_qty ) . '
				' . $this->get_hook_content( 'woocommerce_order_item_meta_start', [ $item_id, $item, $order, false ] ) . '
				' . wc_display_item_meta( $item, [ 'echo' => false ] ) . '
				' . $this->get_hook_content( 'woocommerce_order_item_meta_end', [ $item_id, $item, $order, false ] ) . '
				' . $this->render_order_details_table_item_purchase_note( $order, $product ) . '
			</td>
			<td class="wc-block-order-confirmation-totals__total">
				' . wp_kses_post( $order->get_formatted_line_subtotal( $item ) ) . '
			</td>
		</tr>
	';
}