WC_Order_Data_Store_CPT::get_total_shipping_refunded()publicWC 1.0

Get the total shipping refunded.

Method of the class: WC_Order_Data_Store_CPT{}

No Hooks.

Return

float.

Usage

$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT();
$WC_Order_Data_Store_CPT->get_total_shipping_refunded( $order );
$order(WC_Order) (required)
Order object.

WC_Order_Data_Store_CPT::get_total_shipping_refunded() code WC 9.4.2

public function get_total_shipping_refunded( $order ) {
	global $wpdb;

	$total = $wpdb->get_var(
		$wpdb->prepare(
			"SELECT SUM( order_itemmeta.meta_value )
			FROM {$wpdb->prefix}woocommerce_order_itemmeta AS order_itemmeta
			INNER JOIN $wpdb->posts AS posts ON ( posts.post_type = 'shop_order_refund' AND posts.post_parent = %d )
			INNER JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON ( order_items.order_id = posts.ID AND order_items.order_item_type = 'shipping' )
			WHERE order_itemmeta.order_item_id = order_items.order_item_id
			AND order_itemmeta.meta_key IN ('cost')",
			$order->get_id()
		)
	) ?? 0;

	return abs( $total );
}