• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wp-graphql / wp-graphql-woocommerce / 28450585642

30 Jun 2026 02:06PM UTC coverage: 91.801%. Remained the same
28450585642

Pull #1019

github

web-flow
Merge f9d5287ec into e3cf94438
Pull Request #1019: fix: address WordPress.org plugin review (rename + prefixing + headers)

1330 of 1587 new or added lines in 201 files covered. (83.81%)

1 existing line in 1 file now uncovered.

18531 of 20186 relevant lines covered (91.8%)

153.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.78
/includes/type/object/class-cart-error-types.php
1
<?php
2
/**
3
 * WPObject Types - CartItemError, CouponError, ShippingMethodError
4
 *
5
 * @package WPGraphQL\WooCommerce\Type\WPObject
6
 * @since   0.8.0
7
 */
8

9
namespace WPGraphQL\WooCommerce\Type\WPObject;
10

11
/**
12
 * Class Cart_Error_Types
13
 */
14
class Cart_Error_Types {
15
        /**
16
         * Registers types to the GraphQL schema.
17
         *
18
         * @return void
19
         */
20
        public static function register() {
21
                register_graphql_object_type(
299✔
22
                        'CartItemError',
299✔
23
                        [
299✔
24
                                'description' => static function () {
299✔
25
                                        return __( 'Error that occurred when adding an item to the cart.', 'graphql-for-ecommerce' );
2✔
26
                                },
299✔
27
                                'interfaces'  => [ 'CartError' ],
299✔
28
                                'fields'      => [
299✔
29
                                        'productId'   => [
299✔
30
                                                'type'        => [ 'non_null' => 'Int' ],
299✔
31
                                                'description' => static function () {
299✔
32
                                                        return __( 'Cart item product database ID or global ID', 'graphql-for-ecommerce' );
2✔
33
                                                },
299✔
34
                                                'resolve'     => static function ( array $error ) {
299✔
35
                                                        return ! empty( $error['productId'] ) ? $error['productId'] : null;
2✔
36
                                                },
299✔
37
                                        ],
299✔
38
                                        'quantity'    => [
299✔
39
                                                'type'        => 'Int',
299✔
40
                                                'description' => static function () {
299✔
41
                                                        return __( 'Cart item quantity', 'graphql-for-ecommerce' );
2✔
42
                                                },
299✔
43
                                                'resolve'     => static function ( array $error ) {
299✔
44
                                                        return ! empty( $error['quantity'] ) ? $error['quantity'] : null;
2✔
45
                                                },
299✔
46
                                        ],
299✔
47
                                        'variationId' => [
299✔
48
                                                'type'        => 'Int',
299✔
49
                                                'description' => static function () {
299✔
50
                                                        return __( 'Cart item product variation database ID or global ID', 'graphql-for-ecommerce' );
2✔
51
                                                },
299✔
52
                                                'resolve'     => static function ( array $error ) {
299✔
53
                                                        return ! empty( $error['variationId'] ) ? $error['variationId'] : null;
1✔
54
                                                },
299✔
55
                                        ],
299✔
56
                                        'variation'   => [
299✔
57
                                                'type'        => [ 'list_of' => 'ProductAttributeOutput' ],
299✔
58
                                                'description' => static function () {
299✔
59
                                                        return __( 'Cart item product variation attributes', 'graphql-for-ecommerce' );
2✔
60
                                                },
299✔
61
                                                'resolve'     => static function ( array $error ) {
299✔
62
                                                        return ! empty( $error['variation'] ) ? $error['variation'] : null;
1✔
63
                                                },
299✔
64
                                        ],
299✔
65
                                        'extraData'   => [
299✔
66
                                                'type'        => 'String',
299✔
67
                                                'description' => static function () {
299✔
68
                                                        return __( 'JSON string representation of extra cart item data', 'graphql-for-ecommerce' );
2✔
69
                                                },
299✔
70
                                                'resolve'     => static function ( array $error ) {
299✔
71
                                                        return ! empty( $error['extraData'] ) ? $error['extraData'] : null;
1✔
72
                                                },
299✔
73
                                        ],
299✔
74
                                ],
299✔
75
                        ]
299✔
76
                );
299✔
77

78
                register_graphql_object_type(
299✔
79
                        'CouponError',
299✔
80
                        [
299✔
81
                                'description' => static function () {
299✔
NEW
82
                                        return __( 'Error that occurred when applying a coupon to the cart.', 'graphql-for-ecommerce' );
×
83
                                },
299✔
84
                                'interfaces'  => [ 'CartError' ],
299✔
85
                                'fields'      => [
299✔
86
                                        'code' => [
299✔
87
                                                'type'        => [ 'non_null' => 'String' ],
299✔
88
                                                'description' => static function () {
299✔
NEW
89
                                                        return __( 'Coupon code of the coupon the failed to be applied', 'graphql-for-ecommerce' );
×
90
                                                },
299✔
91
                                                'resolve'     => static function ( array $error ) {
299✔
92
                                                        return ! empty( $error['code'] ) ? $error['code'] : null;
3✔
93
                                                },
299✔
94
                                        ],
299✔
95
                                ],
299✔
96
                        ]
299✔
97
                );
299✔
98

99
                register_graphql_object_type(
299✔
100
                        'ShippingMethodError',
299✔
101
                        [
299✔
102
                                'description' => static function () {
299✔
NEW
103
                                        return __( 'Error that occurred when setting the chosen shipping method for the eventually order.', 'graphql-for-ecommerce' );
×
104
                                },
299✔
105
                                'interfaces'  => [ 'CartError' ],
299✔
106
                                'fields'      => [
299✔
107
                                        'package'      => [
299✔
108
                                                'type'        => [ 'non_null' => 'Integer' ],
299✔
109
                                                'description' => static function () {
299✔
NEW
110
                                                        return __( 'Index of package for desired shipping method', 'graphql-for-ecommerce' );
×
111
                                                },
299✔
112
                                                'resolve'     => static function ( array $error ) {
299✔
113
                                                        return isset( $error['package'] ) && is_int( $error['package'] ) ? $error['package'] : null;
1✔
114
                                                },
299✔
115
                                        ],
299✔
116
                                        'chosenMethod' => [
299✔
117
                                                'type'        => [ 'non_null' => 'String' ],
299✔
118
                                                'description' => static function () {
299✔
NEW
119
                                                        return __( 'ID of chosen shipping rate', 'graphql-for-ecommerce' );
×
120
                                                },
299✔
121
                                                'resolve'     => static function ( array $error ) {
299✔
122
                                                        return ! empty( $error['chosen_method'] ) ? $error['chosen_method'] : null;
1✔
123
                                                },
299✔
124
                                        ],
299✔
125
                                ],
299✔
126
                        ]
299✔
127
                );
299✔
128

129
                register_graphql_object_type(
299✔
130
                        'UnknownCartError',
299✔
131
                        [
299✔
132
                                'description' => static function () {
299✔
NEW
133
                                        return __( 'Error that occurred with no recognizable reason.', 'graphql-for-ecommerce' );
×
134
                                },
299✔
135
                                'interfaces'  => [ 'CartError' ],
299✔
136
                                'fields'      => [],
299✔
137
                        ]
299✔
138
                );
299✔
139
        }
140
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc