created get_refunds() method for WC_Order class
This commit is contained in:
parent
03d9ab0c81
commit
235deeacfe
|
@ -1,18 +1,51 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order
|
* Order
|
||||||
*
|
*
|
||||||
* @class WC_Order
|
* @class WC_Order
|
||||||
* @version 2.1.0
|
* @version 2.2.0
|
||||||
* @package WooCommerce/Classes
|
* @package WooCommerce/Classes
|
||||||
* @category Class
|
* @category Class
|
||||||
* @author WooThemes
|
* @author WooThemes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class WC_Order extends WC_Abstract_Order {
|
class WC_Order extends WC_Abstract_Order {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the order refund.
|
||||||
|
*
|
||||||
|
* @param int|WC_Order $order
|
||||||
|
*/
|
||||||
public function __construct( $order ) {
|
public function __construct( $order ) {
|
||||||
$this->order_type = 'simple';
|
$this->order_type = 'simple';
|
||||||
|
|
||||||
parent::__construct( $order );
|
parent::__construct( $order );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get order refunds
|
||||||
|
*
|
||||||
|
* @since 2.2
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_refunds() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$refunds = array();
|
||||||
|
$refund_items = get_posts(
|
||||||
|
array(
|
||||||
|
'post_type' => 'shop_order',
|
||||||
|
'post_parent' => $this->id,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'fields' => 'ids',
|
||||||
|
'order_type' => 'refund'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ( $refund_items as $refund_id ) {
|
||||||
|
$refunds[] = new WC_Order_Refund( $refund_id );
|
||||||
|
}
|
||||||
|
|
||||||
|
return $refunds;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue