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

wp-graphql / wp-graphql-woocommerce / 27448609176

12 Jun 2026 11:18PM UTC coverage: 91.8% (+0.009%) from 91.791%
27448609176

Pull #1019

github

web-flow
Merge 6a53d4c6b into 2ce9424e1
Pull Request #1019: fix: address WordPress.org plugin review (rename + prefixing + headers)

1327 of 1579 new or added lines in 200 files covered. (84.04%)

35 existing lines in 5 files now uncovered.

18528 of 20183 relevant lines covered (91.8%)

152.68 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(
298✔
22
                        'CartItemError',
298✔
23
                        [
298✔
24
                                'description' => static function () {
298✔
25
                                        return __( 'Error that occurred when adding an item to the cart.', 'graphql-for-ecommerce' );
2✔
26
                                },
298✔
27
                                'interfaces'  => [ 'CartError' ],
298✔
28
                                'fields'      => [
298✔
29
                                        'productId'   => [
298✔
30
                                                'type'        => [ 'non_null' => 'Int' ],
298✔
31
                                                'description' => static function () {
298✔
32
                                                        return __( 'Cart item product database ID or global ID', 'graphql-for-ecommerce' );
2✔
33
                                                },
298✔
34
                                                'resolve'     => static function ( array $error ) {
298✔
35
                                                        return ! empty( $error['productId'] ) ? $error['productId'] : null;
2✔
36
                                                },
298✔
37
                                        ],
298✔
38
                                        'quantity'    => [
298✔
39
                                                'type'        => 'Int',
298✔
40
                                                'description' => static function () {
298✔
41
                                                        return __( 'Cart item quantity', 'graphql-for-ecommerce' );
2✔
42
                                                },
298✔
43
                                                'resolve'     => static function ( array $error ) {
298✔
44
                                                        return ! empty( $error['quantity'] ) ? $error['quantity'] : null;
2✔
45
                                                },
298✔
46
                                        ],
298✔
47
                                        'variationId' => [
298✔
48
                                                'type'        => 'Int',
298✔
49
                                                'description' => static function () {
298✔
50
                                                        return __( 'Cart item product variation database ID or global ID', 'graphql-for-ecommerce' );
2✔
51
                                                },
298✔
52
                                                'resolve'     => static function ( array $error ) {
298✔
53
                                                        return ! empty( $error['variationId'] ) ? $error['variationId'] : null;
1✔
54
                                                },
298✔
55
                                        ],
298✔
56
                                        'variation'   => [
298✔
57
                                                'type'        => [ 'list_of' => 'ProductAttributeOutput' ],
298✔
58
                                                'description' => static function () {
298✔
59
                                                        return __( 'Cart item product variation attributes', 'graphql-for-ecommerce' );
2✔
60
                                                },
298✔
61
                                                'resolve'     => static function ( array $error ) {
298✔
62
                                                        return ! empty( $error['variation'] ) ? $error['variation'] : null;
1✔
63
                                                },
298✔
64
                                        ],
298✔
65
                                        'extraData'   => [
298✔
66
                                                'type'        => 'String',
298✔
67
                                                'description' => static function () {
298✔
68
                                                        return __( 'JSON string representation of extra cart item data', 'graphql-for-ecommerce' );
2✔
69
                                                },
298✔
70
                                                'resolve'     => static function ( array $error ) {
298✔
71
                                                        return ! empty( $error['extraData'] ) ? $error['extraData'] : null;
1✔
72
                                                },
298✔
73
                                        ],
298✔
74
                                ],
298✔
75
                        ]
298✔
76
                );
298✔
77

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

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

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

© 2026 Coveralls, Inc