WC_Order::add_order_item_totals_payment_method_row()protectedWC 1.0

Add total row for the payment method.

Method of the class: WC_Order{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->add_order_item_totals_payment_method_row( $total_rows, $tax_display );
$total_rows(array) (required) (passed by reference — &)
Total rows.
$tax_display(string) (required)
Tax to display.

WC_Order::add_order_item_totals_payment_method_row() code WC 9.6.1

protected function add_order_item_totals_payment_method_row( &$total_rows, $tax_display ) {
	if ( $this->get_total() > 0 && $this->get_payment_method_title() && 'other' !== $this->get_payment_method() ) {
		$value = $this->get_payment_method_title();

		$card_info = $this->get_payment_card_info();
		if ( isset( $card_info['last4'] ) && $card_info['last4'] ) {
			$value .= ' - ' . $card_info['last4'];
		}

		$total_rows['payment_method'] = array(
			'label' => __( 'Payment method:', 'woocommerce' ),
			'value' => $value,
		);
	}
}