woocommerce_printable_order_receipt_line_item_display_data
Filter to customize the HTML that gets rendered for each order line item in the receipt.
$line_item_display_data will be passed (and must be returned) with the following keys:
- inner_html: the HTML text that will go inside a <tr> element, note that wp_kses_post will be applied to this text before actual rendering.
- tr_attributes: attributes (e.g. 'class', 'data', 'style') that will be applied to the <tr> element, as an associative array of attribute name => value.
- row_index: a number that starts at 0 and increases by one for each processed line item.
$line_item_data will contain the following keys:
- type: One of 'product', 'subtotal', 'discount', 'fee', 'shipping_total', 'taxes_total', 'amount_paid'
- title
- amount (formatted with wc_price)
- item (only when type is 'product'), and instance of WC_Order_Item
- quantity (only when type is 'product')
Usage
add_filter( 'woocommerce_printable_order_receipt_line_item_display_data', 'wp_kama_woocommerce_printable_order_receipt_line_item_display_data_filter', 10, 3 ); /** * Function for `woocommerce_printable_order_receipt_line_item_display_data` filter-hook. * * @param string $line_item_display_data Data to use to generate the HTML table row to be rendered for the line item. * @param array $line_item_data The relevant data for the line item for which the HTML table row is being generated. * @param WC_Order $order The order for which the receipt is being generated. * * @return string */ function wp_kama_woocommerce_printable_order_receipt_line_item_display_data_filter( $line_item_display_data, $line_item_data, $order ){ // filter... return $line_item_display_data; }
- $line_item_display_data(string)
- Data to use to generate the HTML table row to be rendered for the line item.
- $line_item_data(array)
- The relevant data for the line item for which the HTML table row is being generated.
- $order(WC_Order)
- The order for which the receipt is being generated.
Changelog
Since 9.0.0 | Introduced. |
Where the hook is called
woocommerce_printable_order_receipt_line_item_display_data
woocommerce/src/Internal/ReceiptRendering/ReceiptRenderingEngine.php 172
$line_item_display_data = apply_filters( 'woocommerce_printable_order_receipt_line_item_display_data', $line_item_display_data, $line_item_data, $order );