2021-07-05 13:51:52 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Mutation - createUpdate
|
|
|
|
|
*
|
|
|
|
|
* Registers mutation for update an coupon.
|
|
|
|
|
*
|
|
|
|
|
* @package WPGraphQL\WooCommerce\Mutation
|
|
|
|
|
* @since 0.9.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace WPGraphQL\WooCommerce\Mutation;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Coupon_Update
|
|
|
|
|
*/
|
|
|
|
|
class Coupon_Update {
|
|
|
|
|
/**
|
|
|
|
|
* Registers mutation
|
2023-06-13 23:17:02 +03:00
|
|
|
*
|
|
|
|
|
* @return void
|
2021-07-05 13:51:52 -04:00
|
|
|
*/
|
|
|
|
|
public static function register_mutation() {
|
|
|
|
|
register_graphql_mutation(
|
|
|
|
|
'updateCoupon',
|
2022-08-26 14:53:36 -04:00
|
|
|
[
|
2021-07-05 13:51:52 -04:00
|
|
|
'inputFields' => self::get_input_fields(),
|
|
|
|
|
'outputFields' => Coupon_Create::get_output_fields(),
|
2022-08-26 14:53:36 -04:00
|
|
|
'mutateAndGetPayload' => [ Coupon_Create::class, 'mutate_and_get_payload' ],
|
|
|
|
|
]
|
2021-07-05 13:51:52 -04:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Defines the mutation input field configuration
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public static function get_input_fields() {
|
|
|
|
|
return array_merge(
|
|
|
|
|
Coupon_Create::get_input_fields(),
|
2022-08-26 14:53:36 -04:00
|
|
|
[
|
|
|
|
|
'id' => [
|
|
|
|
|
'type' => [ 'non_null' => 'ID' ],
|
2026-03-30 23:37:51 -04:00
|
|
|
'description' => static function () {
|
2026-06-30 10:16:21 -04:00
|
|
|
return __( 'Unique identifier for the object.', 'graphql-for-ecommerce' );
|
2026-03-30 23:37:51 -04:00
|
|
|
},
|
2022-08-26 14:53:36 -04:00
|
|
|
],
|
|
|
|
|
'code' => [
|
2021-07-05 13:51:52 -04:00
|
|
|
'type' => 'String',
|
2026-03-30 23:37:51 -04:00
|
|
|
'description' => static function () {
|
2026-06-30 10:16:21 -04:00
|
|
|
return __( 'Coupon code.', 'graphql-for-ecommerce' );
|
2026-03-30 23:37:51 -04:00
|
|
|
},
|
2022-08-26 14:53:36 -04:00
|
|
|
],
|
|
|
|
|
]
|
2021-07-05 13:51:52 -04:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|