Automattic\WooCommerce\Internal\DataStores\Orders

OrdersTableDataStore::get_total_refunded()publicWC 1.0

Get amount already refunded.

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

No Hooks.

Return

float. Refunded amount.

Usage

$OrdersTableDataStore = new OrdersTableDataStore();
$OrdersTableDataStore->get_total_refunded( $order );
$order(\WC_Order) (required)
Order object.

Code of OrdersTableDataStore::get_total_refunded() WC 7.1.0

public function get_total_refunded( $order ) {
	global $wpdb;
	$order_table = self::get_orders_table_name();
	$total       = $wpdb->get_var(
		$wpdb->prepare(
		// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $order_table is hardcoded.
			"
SELECT SUM( total_amount ) FROM $order_table
WHERE
    type = %s AND
    parent_order_id = %d
;
",
			// phpcs:enable
			'shop_order_refund',
			$order->get_id()
		)
	);
	return -1 * ( isset( $total ) ? $total : 0 );
}