Skip to content

Commit bc4992f

Browse files
committed
chore: New feature stubbed out
1 parent 32f8ba2 commit bc4992f

File tree

5 files changed

+151
-0
lines changed

5 files changed

+151
-0
lines changed

includes/class-type-registry.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ public function init() {
177177
Mutation\Order_Update::register_mutation();
178178
Mutation\Order_Delete::register_mutation();
179179
Mutation\Order_Delete_Items::register_mutation();
180+
Mutation\Refund_Create::register_mutation();
181+
Mutation\Refund_Delete::register_mutation();
180182
Mutation\Checkout::register_mutation();
181183
Mutation\Review_Write::register_mutation();
182184
Mutation\Review_Update::register_mutation();

includes/class-wp-graphql-woocommerce.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ private function includes() {
338338
require $include_directory_path . 'mutation/class-order-delete-items.php';
339339
require $include_directory_path . 'mutation/class-order-delete.php';
340340
require $include_directory_path . 'mutation/class-order-update.php';
341+
require $include_directory_path . 'mutation/class-refund-create.php';
342+
require $include_directory_path . 'mutation/class-refund-delete.php';
341343
require $include_directory_path . 'mutation/class-review-write.php';
342344
require $include_directory_path . 'mutation/class-review-delete-restore.php';
343345
require $include_directory_path . 'mutation/class-review-update.php';
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Mutation - createRefund
4+
*
5+
* Registers mutation for creating a refund on an order.
6+
*
7+
* @package WPGraphQL\WooCommerce\Mutation
8+
* @since TDB
9+
*/
10+
11+
namespace WPGraphQL\WooCommerce\Mutation;
12+
13+
use GraphQL\Error\UserError;
14+
use GraphQL\Type\Definition\ResolveInfo;
15+
use WC_Order_Factory;
16+
use WPGraphQL\AppContext;
17+
use WPGraphQL\WooCommerce\Data\Mutation\Order_Mutation;
18+
use WPGraphQL\WooCommerce\Model\Order;
19+
20+
/**
21+
* Class Refund_Create
22+
*/
23+
class Refund_Create {
24+
/**
25+
* Registers mutation
26+
*
27+
* @return void
28+
*/
29+
public static function register_mutation() {
30+
register_graphql_mutation(
31+
'createRefund',
32+
[
33+
'inputFields' => self::get_input_fields(),
34+
'outputFields' => self::get_output_fields(),
35+
'mutateAndGetPayload' => self::mutate_and_get_payload(),
36+
]
37+
);
38+
}
39+
40+
/**
41+
* Defines the mutation input field configuration
42+
*
43+
* @return array
44+
*/
45+
public static function get_input_fields() {
46+
return [];
47+
}
48+
49+
/**
50+
* Defines the mutation output field configuration
51+
*
52+
* @return array
53+
*/
54+
public static function get_output_fields() {
55+
return [];
56+
}
57+
58+
/**
59+
* Defines the mutation data modification closure.
60+
*
61+
* @return callable
62+
*/
63+
public static function mutate_and_get_payload() {
64+
return static function ( $input, AppContext $context, ResolveInfo $info ) {
65+
return [ 'id' => 0 ];
66+
};
67+
}
68+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Mutation - deleteRefund
4+
*
5+
* Registers mutation for delete a refund on an order.
6+
*
7+
* @package WPGraphQL\WooCommerce\Mutation
8+
* @since TDB
9+
*/
10+
11+
namespace WPGraphQL\WooCommerce\Mutation;
12+
13+
use GraphQL\Error\UserError;
14+
use GraphQL\Type\Definition\ResolveInfo;
15+
use WC_Order_Factory;
16+
use WPGraphQL\AppContext;
17+
use WPGraphQL\WooCommerce\Data\Mutation\Order_Mutation;
18+
use WPGraphQL\WooCommerce\Model\Order;
19+
20+
/**
21+
* Class Refund_Delete
22+
*/
23+
class Refund_Delete {
24+
/**
25+
* Registers mutation
26+
*
27+
* @return void
28+
*/
29+
public static function register_mutation() {
30+
register_graphql_mutation(
31+
'deleteRefund',
32+
[
33+
'inputFields' => self::get_input_fields(),
34+
'outputFields' => self::get_output_fields(),
35+
'mutateAndGetPayload' => self::mutate_and_get_payload(),
36+
]
37+
);
38+
}
39+
40+
/**
41+
* Defines the mutation input field configuration
42+
*
43+
* @return array
44+
*/
45+
public static function get_input_fields() {
46+
return [];
47+
}
48+
49+
/**
50+
* Defines the mutation output field configuration
51+
*
52+
* @return array
53+
*/
54+
public static function get_output_fields() {
55+
return [];
56+
}
57+
58+
/**
59+
* Defines the mutation data modification closure.
60+
*
61+
* @return callable
62+
*/
63+
public static function mutate_and_get_payload() {
64+
return static function ( $input, AppContext $context, ResolveInfo $info ) {
65+
return [ 'id' => 0 ];
66+
};
67+
}
68+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
class RefundMutationsTest extends \Tests\WPGraphQL\WooCommerce\TestCase\WooGraphQLTestCase {
4+
public function testCreateRefundMutation() {
5+
$this->markTestIncomplete();
6+
}
7+
8+
public function testDeleteRefundMutation() {
9+
$this->markTestIncomplete();
10+
}
11+
}

0 commit comments

Comments
 (0)