Files
wp-graphql-woocommerce/includes/model/class-refund.php
T
Geoffrey K TaylorandGitHub f59872ae89 Coupon mutations added. (#510)
* Coupon mutations implemented and tested
* Vendor files no longer versioned and package workflow implemented
2021-07-05 13:51:52 -04:00

64 lines
1.6 KiB
PHP

<?php
/**
* Model - Refund
*
* Resolves refund crud object model
*
* @package WPGraphQL\WooCommerce\Model
* @since 0.0.1
*/
namespace WPGraphQL\WooCommerce\Model;
use GraphQLRelay\Relay;
use WPGraphQL\Model\Post;
use WC_Order_Refund;
/**
* Class Refund.
*/
class Refund extends Order {
/**
* Hold order post type slug
*
* @var string $post_type
*/
protected $post_type = 'shop_order_refund';
/**
* Initializes the Refund field resolvers.
*/
protected function init() {
if ( empty( $this->fields ) ) {
Post::init();
$fields = array(
'id' => function() {
return ! empty( $this->wc_data->get_id() ) ? Relay::toGlobalId( 'shop_order_refund', $this->wc_data->get_id() ) : null;
},
'title' => function() {
return ! empty( $this->wc_data->get_post_title() ) ? $this->wc_data->get_post_title() : null;
},
'amount' => function() {
return ! empty( $this->wc_data->get_amount() ) ? $this->wc_data->get_amount() : null;
},
'reason' => function() {
return ! empty( $this->wc_data->get_reason() ) ? $this->wc_data->get_reason() : null;
},
'refunded_by_id' => array(
'callback' => function() {
return ! empty( $this->wc_data->get_refunded_by() ) ? $this->wc_data->get_refunded_by() : null;
},
'capability' => 'list_users',
),
'date' => function() {
return ! empty( $this->wc_data->get_date_modified() ) ? $this->wc_data->get_date_modified() : null;
},
);
$this->fields = array_merge( $this->fields, $fields );
}
}
}