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.

Метод класса: Controller{}

Хуков нет.

Возвращает

Строку.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_total_formatted( $order_id );
$order_id(int) (обязательный)
Order ID.

Код Controller::get_total_formatted() WC 8.7.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 );
}