Automattic\WooCommerce\Admin\API\Reports

Controller::get_total_formatted()protectedWC 1.0

Get the order total with the related currency formatting. Returns the parent order total if the order is actually a refund.

Method of the class: Controller{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_total_formatted( $order_id );
$order_id(int) (required)
Order ID.

Controller::get_total_formatted() code WC 7.3.0

protected function get_total_formatted( $order_id ) {
	$order = wc_get_order( $order_id );

	if ( ! $order instanceof \WC_Order && ! $order instanceof \WC_Order_Refund ) {
		return null;
	}

	if ( 'shop_order_refund' === $order->get_type() ) {
		$order = wc_get_order( $order->get_parent_id() );
	}

	return wp_strip_all_tags( html_entity_decode( $order->get_formatted_order_total() ), true );
}