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

wp-graphql / wp-graphql-woocommerce / 28451172886

30 Jun 2026 02:16PM UTC coverage: 91.801%. Remained the same
28451172886

push

github

web-flow
fix: address WordPress.org plugin review (rename + prefixing + headers) (#1019)

* fix: address WordPress.org plugin review feedback

- Prefix the session transaction queue transient with the plugin's
  graphql_woocommerce_ namespace instead of the generic "woo_" word, to
  avoid collisions (Plugin Directory: prefix data storage).
- Declare the WooCommerce dependency via the "Requires Plugins: woocommerce"
  plugin header.
- Bump README.txt "Tested up to" to 7.0.
- Ship composer.json in the distributed plugin (drop it, and composer.lock,
  from composer archive excludes) so the build is reproducible/reviewable.

* chore: rename plugin to "GraphQL for eCommerce" for trademark compliance

The WordPress.org plugin review flagged the display name/slug for beginning
with the "WPGraphQL" trademark (and the "WooGraphQL" portmanteau of the
WooCommerce mark), which can imply official affiliation.

- Display name (plugin header + readme title) -> "GraphQL for eCommerce".
- Slug/text domain -> "graphql-for-ecommerce" (header, all i18n string
  literals, and the PHPCS WordPress.WP.I18n text_domain config).
- Update user-facing notices/errors that named the old plugin.

"WooGraphQL" remains the project's informal nickname (repo, docs, community),
just not in the WordPress.org directory's official name/slug. Internal file
names and GitHub URLs are unchanged.

* fix: keep test-only dev deps out of the committed composer.json

The committed manifest mirrors develop (lint/stan dev deps only); CI adds the
test suite deps at runtime via `composer installTestEnv`. A previous commit
captured the installTestEnv-modified composer.json, desyncing it from
composer.lock and breaking `composer install` in CI.

* chore: regenerate composer.lock (refresh dev dependencies)

Regenerate the lock from the manifest so it is in sync (fixes the CI
`composer install` failure) and refresh dependencies in the process —
firebase/php-jwt v7.0.4 -> v7.1.0 plus 11 others, with vendor-prefixed
... (continued)

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.03
/includes/mutation/class-shipping-zone-method-remove.php
1
<?php
2
/**
3
 * Mutation - removeMethodFromShippingZone
4
 *
5
 * Registers mutation for removing a shipping method from a shipping zone.
6
 *
7
 * @package WPGraphQL\WooCommerce\Mutation
8
 * @since 0.20.0
9
 */
10

11
namespace WPGraphQL\WooCommerce\Mutation;
12

13
use GraphQL\Error\UserError;
14
use GraphQL\Type\Definition\ResolveInfo;
15
use WPGraphQL\AppContext;
16
use WPGraphQL\WooCommerce\Model\Shipping_Method;
17

18
/**
19
 * Class - Shipping_Zone_Method_Remove
20
 */
21
class Shipping_Zone_Method_Remove {
22
        /**
23
         * Registers mutation
24
         *
25
         * @return void
26
         */
27
        public static function register_mutation() {
28
                register_graphql_mutation(
299✔
29
                        'removeMethodFromShippingZone',
299✔
30
                        [
299✔
31
                                'inputFields'         => self::get_input_fields(),
299✔
32
                                'outputFields'        => self::get_output_fields(),
299✔
33
                                'mutateAndGetPayload' => self::mutate_and_get_payload(),
299✔
34
                        ]
299✔
35
                );
299✔
36
        }
37

38
        /**
39
         * Defines the mutation input field configuration
40
         *
41
         * @return array
42
         */
43
        public static function get_input_fields() {
44
                return [
299✔
45
                        'zoneId'     => [
299✔
46
                                'type'        => [ 'non_null' => 'Int' ],
299✔
47
                                'description' => static function () {
299✔
48
                                        return __( 'The ID of the shipping zone to delete.', 'graphql-for-ecommerce' );
2✔
49
                                },
299✔
50
                        ],
299✔
51
                        'instanceId' => [
299✔
52
                                'type'        => [ 'non_null' => 'Int' ],
299✔
53
                                'description' => static function () {
299✔
54
                                        return __( 'Shipping method instance ID', 'graphql-for-ecommerce' );
2✔
55
                                },
299✔
56
                        ],
299✔
57
                ];
299✔
58
        }
59

60
        /**
61
         * Defines the mutation output field configuration
62
         *
63
         * @return array
64
         */
65
        public static function get_output_fields() {
66
                return [
299✔
67
                        'shippingZone'  => [
299✔
68
                                'type'    => 'ShippingZone',
299✔
69
                                'resolve' => static function ( $payload, array $args, AppContext $context ) {
299✔
70
                                        return $context->get_loader( 'shipping_zone' )->load( $payload['zone_id'] );
1✔
71
                                },
299✔
72
                        ],
299✔
73
                        'removedMethod' => [
299✔
74
                                'type'    => 'ShippingZoneToShippingMethodConnectionEdge',
299✔
75
                                'resolve' => static function ( $payload, array $args, AppContext $context ) {
299✔
76
                                        return [
1✔
77
                                                // Call the Shipping_Method constructor directly because "$payload['method']" is a non-scalar value.
78
                                                'node'   => new Shipping_Method( $payload['method'] ),
1✔
79
                                                'source' => $context->get_loader( 'shipping_zone' )->load( $payload['zone_id'] ),
1✔
80
                                        ];
1✔
81
                                },
299✔
82
                        ],
299✔
83
                ];
299✔
84
        }
85

86
        /**
87
         * Defines the mutation data modification closure.
88
         *
89
         * @return callable
90
         */
91
        public static function mutate_and_get_payload() {
92
                return static function ( $input, AppContext $context, ResolveInfo $info ) {
299✔
93
                        if ( ! \wc_shipping_enabled() ) {
1✔
NEW
94
                                throw new UserError( __( 'Shipping is disabled.', 'graphql-for-ecommerce' ), 404 );
×
95
                        }
96

97
                        if ( ! \wc_rest_check_manager_permissions( 'settings', 'delete' ) ) {
1✔
98
                                throw new UserError( __( 'Sorry, you are not allowed to remove shipping methods', 'graphql-for-ecommerce' ), \rest_authorization_required_code() );
1✔
99
                        }
100

101
                        $instance_id = $input['instanceId'];
1✔
102
                        $zone_id     = $input['zoneId'];
1✔
103
                        /** @var \WC_Shipping_Zone|false $zone */
104
                        $zone = \WC_Shipping_Zones::get_zone_by( 'zone_id', $zone_id );
1✔
105

106
                        if ( false === $zone ) {
1✔
NEW
107
                                throw new UserError( __( 'Invalid shipping zone ID.', 'graphql-for-ecommerce' ) );
×
108
                        }
109

110
                        if ( 0 === $zone->get_id() ) {
1✔
NEW
111
                                throw new UserError( __( 'Invalid shipping zone ID.', 'graphql-for-ecommerce' ) );
×
112
                        }
113

114
                        $methods = $zone->get_shipping_methods();
1✔
115
                        $method  = false;
1✔
116

117
                        foreach ( $methods as $shipping_method ) {
1✔
118
                                if ( $shipping_method->instance_id === $instance_id ) {
1✔
119
                                        $method = $shipping_method;
1✔
120
                                        break;
1✔
121
                                }
122
                        }
123

124
                        if ( ! $method ) {
1✔
NEW
125
                                throw new UserError( __( 'Invalid shipping method instance ID.', 'graphql-for-ecommerce' ) );
×
126
                        }
127

128
                        /**
129
                         * Filter shipping method object before it's removed from the shipping zone.
130
                         *
131
                         * @param \WC_Shipping_Method $method  The shipping method to be deleted.
132
                         * @param \WC_Shipping_Zone   $zone    The shipping zone object.
133
                         * @param array               $input   Request input.
134
                         */
135
                        $method = apply_filters( 'graphql_woocommerce_shipping_zone_method_add', $method, $zone, $input );
1✔
136

137
                        $zone->delete_shipping_method( $instance_id );
1✔
138

139
                        return [
1✔
140
                                'zone_id' => $zone_id,
1✔
141
                                'zone'    => $zone,
1✔
142
                                'method'  => $method,
1✔
143
                        ];
1✔
144
                };
299✔
145
        }
146
}
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