WC_Order::get_refundspublicWC 2.2

Returns an array of WC_Order_Refund objects for the order.

Utilizes object cache to store refunds to avoid extra DB calls.

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

Хуков нет.

Возвращает

WC_Order_Refund[].

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

$WC_Order = new WC_Order();
$WC_Order->get_refunds();

Заметки

Список изменений

С версии 2.2 Введена.

Код WC_Order::get_refunds() WC 10.5.2

public function get_refunds() {
	$cache_key = WC_Cache_Helper::get_cache_prefix( 'orders' ) . 'refunds' . $this->get_id();
	$refunds   = wp_cache_get( $cache_key, $this->cache_group );

	if ( false === $refunds ) {
		$refunds = wc_get_orders(
			array(
				'type'   => 'shop_order_refund',
				'parent' => $this->get_id(),
				'limit'  => -1,
			)
		);
		wp_cache_set( $cache_key, $refunds, $this->cache_group );
	}

	$this->refunds = array();

	if ( ! empty( $refunds ) && is_array( $refunds ) ) {
		foreach ( $refunds as $refund ) {
			if ( $refund instanceof WC_Order_Refund ) {
				$this->refunds[] = $refund;
			}
		}
	}

	return $this->refunds;
}