Skip to content

Commit

Permalink
feat: applied coupon description field added
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Oct 22, 2021
1 parent 1d52337 commit ebf2122
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions includes/type/object/class-cart-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ public static function register_applied_coupon() {
return \wc_graphql_price( $tax );
},
),
'description' => array(
'type' => 'String',
'description' => __( 'Description of applied coupon', 'wp-graphql-woocommerce' ),
'resolve' => function( $source, array $args ) {
$coupon = new \WC_Coupon( $source );
return $coupon->get_description();
},
),
),
)
);
Expand Down
7 changes: 5 additions & 2 deletions tests/wpunit/CartMutationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ public function testApplyCouponMutation() {
$this->factory->coupon->create(
array(
'amount' => 0.5,
'product_ids' => array( $product_id )
'product_ids' => array( $product_id ),
'description' => 'lorem ipsum dolor',
)
)
);
Expand All @@ -445,6 +446,7 @@ public function testApplyCouponMutation() {
cart {
appliedCoupons {
code
description
}
contents {
nodes {
Expand Down Expand Up @@ -484,7 +486,8 @@ public function testApplyCouponMutation() {
$this->expectedNode(
'applyCoupon.cart.appliedCoupons',
array(
'code' => $coupon_code,
'code' => $coupon_code,
'description' => 'lorem ipsum dolor',
)
),
$this->expectedNode(
Expand Down

0 comments on commit ebf2122

Please sign in to comment.