Skip to content

Commit a3dfa80

Browse files
authored
feat: applied coupon description field added (#572)
1 parent 1d52337 commit a3dfa80

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

includes/type/object/class-cart-type.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,14 @@ public static function register_applied_coupon() {
618618
return \wc_graphql_price( $tax );
619619
},
620620
),
621+
'description' => array(
622+
'type' => 'String',
623+
'description' => __( 'Description of applied coupon', 'wp-graphql-woocommerce' ),
624+
'resolve' => function( $source, array $args ) {
625+
$coupon = new \WC_Coupon( $source );
626+
return $coupon->get_description();
627+
},
628+
),
621629
),
622630
)
623631
);

tests/wpunit/CartMutationsTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ public function testApplyCouponMutation() {
427427
$this->factory->coupon->create(
428428
array(
429429
'amount' => 0.5,
430-
'product_ids' => array( $product_id )
430+
'product_ids' => array( $product_id ),
431+
'description' => 'lorem ipsum dolor',
431432
)
432433
)
433434
);
@@ -445,6 +446,7 @@ public function testApplyCouponMutation() {
445446
cart {
446447
appliedCoupons {
447448
code
449+
description
448450
}
449451
contents {
450452
nodes {
@@ -484,7 +486,8 @@ public function testApplyCouponMutation() {
484486
$this->expectedNode(
485487
'applyCoupon.cart.appliedCoupons',
486488
array(
487-
'code' => $coupon_code,
489+
'code' => $coupon_code,
490+
'description' => 'lorem ipsum dolor',
488491
)
489492
),
490493
$this->expectedNode(

0 commit comments

Comments
 (0)