From 74bb15f84e7030e170ea5aae609af326a3e9e047 Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 11 Jul 2019 16:43:36 -0400 Subject: [PATCH 1/2] "Actions" and "Filters" classes renamed and refactored. --- ...ters.php => class-core-schema-filters.php} | 80 ++--------------- ...ss-actions.php => class-type-registry.php} | 24 ++--- includes/class-woocommerce-filters.php | 88 +++++++++++++++++++ includes/class-wp-graphql-woocommerce.php | 5 +- vendor/composer/autoload_classmap.php | 5 +- vendor/composer/autoload_static.php | 5 +- 6 files changed, 110 insertions(+), 97 deletions(-) rename includes/{class-filters.php => class-core-schema-filters.php} (69%) rename includes/{class-actions.php => class-type-registry.php} (95%) create mode 100644 includes/class-woocommerce-filters.php diff --git a/includes/class-filters.php b/includes/class-core-schema-filters.php similarity index 69% rename from includes/class-filters.php rename to includes/class-core-schema-filters.php index d2582e199..ff9258798 100644 --- a/includes/class-filters.php +++ b/includes/class-core-schema-filters.php @@ -1,8 +1,6 @@ $baseDir . '/includes/class-actions.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Cart_Items' => $baseDir . '/includes/connection/class-cart-items.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Coupons' => $baseDir . '/includes/connection/class-coupons.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Customers' => $baseDir . '/includes/connection/class-customers.php', @@ -21,6 +20,7 @@ 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Variation_Attributes' => $baseDir . '/includes/connection/class-variation-attributes.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Connection' => $baseDir . '/includes/connection/class-wc-connection.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Terms' => $baseDir . '/includes/connection/class-wc-terms.php', + 'WPGraphQL\\Extensions\\WooCommerce\\Core_Schema_Filters' => $baseDir . '/includes/class-core-schema-filters.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Cart_Item_Connection_Resolver' => $baseDir . '/includes/data/connection/class-cart-item-connection-resolver.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Coupon_Connection_Resolver' => $baseDir . '/includes/data/connection/class-coupon-connection-resolver.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Customer_Connection_Resolver' => $baseDir . '/includes/data/connection/class-customer-connection-resolver.php', @@ -42,7 +42,6 @@ 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Mutation\\Checkout_Mutation' => $baseDir . '/includes/data/mutation/class-checkout-mutation.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Mutation\\Customer_Mutation' => $baseDir . '/includes/data/mutation/class-customer-mutation.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Mutation\\Order_Mutation' => $baseDir . '/includes/data/mutation/class-order-mutation.php', - 'WPGraphQL\\Extensions\\WooCommerce\\Filters' => $baseDir . '/includes/class-filters.php', 'WPGraphQL\\Extensions\\WooCommerce\\Model\\Coupon' => $baseDir . '/includes/model/class-coupon.php', 'WPGraphQL\\Extensions\\WooCommerce\\Model\\Crud_CPT' => $baseDir . '/includes/model/class-crud-cpt.php', 'WPGraphQL\\Extensions\\WooCommerce\\Model\\Customer' => $baseDir . '/includes/model/class-customer.php', @@ -108,6 +107,8 @@ 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Shipping_Method_Type' => $baseDir . '/includes/type/object/class-shipping-method-type.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Tax_Rate_Type' => $baseDir . '/includes/type/object/class-tax-rate-type.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Variation_Attribute_Type' => $baseDir . '/includes/type/object/class-variation-attribute-type.php', + 'WPGraphQL\\Extensions\\WooCommerce\\Type_Registry' => $baseDir . '/includes/class-type-registry.php', 'WPGraphQL\\Extensions\\WooCommerce\\Utils\\QL_Session_Handler' => $baseDir . '/includes/utils/class-ql-session-handler.php', + 'WPGraphQL\\Extensions\\WooCommerce\\WooCommerce_Filters' => $baseDir . '/includes/class-woocommerce-filters.php', 'WP_GraphQL_WooCommerce' => $baseDir . '/includes/class-wp-graphql-woocommerce.php', ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 1e1649df5..fa09ad714 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -21,7 +21,6 @@ class ComposerStaticInitee0d17af17b841ed3a93c4a0e5cc5e5f ); public static $classMap = array ( - 'WPGraphQL\\Extensions\\WooCommerce\\Actions' => __DIR__ . '/../..' . '/includes/class-actions.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Cart_Items' => __DIR__ . '/../..' . '/includes/connection/class-cart-items.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Coupons' => __DIR__ . '/../..' . '/includes/connection/class-coupons.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Customers' => __DIR__ . '/../..' . '/includes/connection/class-customers.php', @@ -36,6 +35,7 @@ class ComposerStaticInitee0d17af17b841ed3a93c4a0e5cc5e5f 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Variation_Attributes' => __DIR__ . '/../..' . '/includes/connection/class-variation-attributes.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Connection' => __DIR__ . '/../..' . '/includes/connection/class-wc-connection.php', 'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Terms' => __DIR__ . '/../..' . '/includes/connection/class-wc-terms.php', + 'WPGraphQL\\Extensions\\WooCommerce\\Core_Schema_Filters' => __DIR__ . '/../..' . '/includes/class-core-schema-filters.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Cart_Item_Connection_Resolver' => __DIR__ . '/../..' . '/includes/data/connection/class-cart-item-connection-resolver.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Coupon_Connection_Resolver' => __DIR__ . '/../..' . '/includes/data/connection/class-coupon-connection-resolver.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Customer_Connection_Resolver' => __DIR__ . '/../..' . '/includes/data/connection/class-customer-connection-resolver.php', @@ -57,7 +57,6 @@ class ComposerStaticInitee0d17af17b841ed3a93c4a0e5cc5e5f 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Mutation\\Checkout_Mutation' => __DIR__ . '/../..' . '/includes/data/mutation/class-checkout-mutation.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Mutation\\Customer_Mutation' => __DIR__ . '/../..' . '/includes/data/mutation/class-customer-mutation.php', 'WPGraphQL\\Extensions\\WooCommerce\\Data\\Mutation\\Order_Mutation' => __DIR__ . '/../..' . '/includes/data/mutation/class-order-mutation.php', - 'WPGraphQL\\Extensions\\WooCommerce\\Filters' => __DIR__ . '/../..' . '/includes/class-filters.php', 'WPGraphQL\\Extensions\\WooCommerce\\Model\\Coupon' => __DIR__ . '/../..' . '/includes/model/class-coupon.php', 'WPGraphQL\\Extensions\\WooCommerce\\Model\\Crud_CPT' => __DIR__ . '/../..' . '/includes/model/class-crud-cpt.php', 'WPGraphQL\\Extensions\\WooCommerce\\Model\\Customer' => __DIR__ . '/../..' . '/includes/model/class-customer.php', @@ -123,7 +122,9 @@ class ComposerStaticInitee0d17af17b841ed3a93c4a0e5cc5e5f 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Shipping_Method_Type' => __DIR__ . '/../..' . '/includes/type/object/class-shipping-method-type.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Tax_Rate_Type' => __DIR__ . '/../..' . '/includes/type/object/class-tax-rate-type.php', 'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Variation_Attribute_Type' => __DIR__ . '/../..' . '/includes/type/object/class-variation-attribute-type.php', + 'WPGraphQL\\Extensions\\WooCommerce\\Type_Registry' => __DIR__ . '/../..' . '/includes/class-type-registry.php', 'WPGraphQL\\Extensions\\WooCommerce\\Utils\\QL_Session_Handler' => __DIR__ . '/../..' . '/includes/utils/class-ql-session-handler.php', + 'WPGraphQL\\Extensions\\WooCommerce\\WooCommerce_Filters' => __DIR__ . '/../..' . '/includes/class-woocommerce-filters.php', 'WP_GraphQL_WooCommerce' => __DIR__ . '/../..' . '/includes/class-wp-graphql-woocommerce.php', ); From 158e7ff64d9de7d65edb6e70bfd184ae3a77283f Mon Sep 17 00:00:00 2001 From: Geoff Taylor Date: Thu, 11 Jul 2019 18:08:02 -0400 Subject: [PATCH 2/2] Unnecessary "use" statements removed. --- includes/class-core-schema-filters.php | 1 - includes/class-type-registry.php | 205 ++++++------------ includes/connection/class-posts.php | 2 - includes/connection/class-wc-terms.php | 2 - includes/data/class-factory.php | 1 - .../class-coupon-connection-resolver.php | 2 - .../class-customer-connection-resolver.php | 1 - .../class-order-connection-resolver.php | 1 - .../class-post-connection-resolver.php | 1 - .../class-product-connection-resolver.php | 1 - ...ariation-attribute-connection-resolver.php | 2 +- .../class-wc-terms-connection-resolver.php | 1 - includes/model/class-customer.php | 1 - includes/model/class-product-variation.php | 1 - includes/model/trait-shop-manager-caps.php | 1 - includes/mutation/class-cart-empty.php | 4 + includes/mutation/class-customer-register.php | 2 +- includes/mutation/class-customer-update.php | 2 +- includes/type/enum/class-product-types.php | 2 - includes/type/enum/class-tax-class.php | 4 +- includes/type/object/class-cart-type.php | 2 - .../object/class-product-attribute-type.php | 4 - .../object/class-product-category-type.php | 2 - .../object/class-product-download-type.php | 4 - .../object/class-product-variation-type.php | 2 +- includes/type/object/class-refund-type.php | 7 +- .../object/class-shipping-method-type.php | 2 +- includes/type/object/class-tax-rate-type.php | 2 +- 28 files changed, 82 insertions(+), 180 deletions(-) diff --git a/includes/class-core-schema-filters.php b/includes/class-core-schema-filters.php index ff9258798..3dfc2310e 100644 --- a/includes/class-core-schema-filters.php +++ b/includes/class-core-schema-filters.php @@ -10,7 +10,6 @@ use WPGraphQL\Extensions\WooCommerce\Data\Connection\Post_Connection_Resolver; use WPGraphQL\Extensions\WooCommerce\Data\Connection\WC_Terms_Connection_Resolver; -use WPGraphQL\Extensions\WooCommerce\Data\Factory; use WPGraphQL\Extensions\WooCommerce\Data\Loader\WC_Customer_Loader; use WPGraphQL\Extensions\WooCommerce\Data\Loader\WC_Post_Crud_Loader; diff --git a/includes/class-type-registry.php b/includes/class-type-registry.php index 392c5527a..13ba53622 100644 --- a/includes/class-type-registry.php +++ b/includes/class-type-registry.php @@ -8,77 +8,6 @@ namespace WPGraphQL\Extensions\WooCommerce; -use WPGraphQL\AppContext; -use WPGraphQL\Data\DataSource; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Backorders; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Catalog_Visibility; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Countries; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Customer_Connection_Orderby_Enum; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Discount_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Manage_Stock; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Order_Status; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Product_Types; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Stock_Status; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Class; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Status; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\WC_Connection_Orderby_Enum; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Rate_Connection_Orderby_Enum; -use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Pricing_Field_Format; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Customer_Address_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Product_Attribute_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\WC_Connection_Orderby_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Tax_Rate_Connection_Orderby_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Fee_Line_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Line_Item_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Meta_Data_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Shipping_Line_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Create_Account_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Cart_Item_Quantity_Input; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Coupon_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Order_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Order_Item_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Refund_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Variation_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Attribute_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Download_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Customer_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Customer_Address_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Tax_Rate_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Shipping_Method_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Cart_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Variation_Attribute_Type; -use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Category_Type; -use WPGraphQL\Extensions\WooCommerce\Connection\Posts; -use WPGraphQL\Extensions\WooCommerce\Connection\WC_Terms; -use WPGraphQL\Extensions\WooCommerce\Connection\Coupons; -use WPGraphQL\Extensions\WooCommerce\Connection\Products; -use WPGraphQL\Extensions\WooCommerce\Connection\Orders; -use WPGraphQL\Extensions\WooCommerce\Connection\Order_Items; -use WPGraphQL\Extensions\WooCommerce\Connection\Refunds; -use WPGraphQL\Extensions\WooCommerce\Connection\Product_Attributes; -use WPGraphQL\Extensions\WooCommerce\Connection\Variation_Attributes; -use WPGraphQL\Extensions\WooCommerce\Connection\Product_Gallery; -use WPGraphQL\Extensions\WooCommerce\Connection\Customers; -use WPGraphQL\Extensions\WooCommerce\Connection\Tax_Rates; -use WPGraphQL\Extensions\WooCommerce\Connection\Shipping_Methods; -use WPGraphQL\Extensions\WooCommerce\Connection\Cart_Items; -use WPGraphQL\Extensions\WooCommerce\Mutation\Customer_Register; -use WPGraphQL\Extensions\WooCommerce\Mutation\Customer_Update; -use WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Add_Item; -use WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Update_Item_Quantities; -use WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Remove_Items; -use WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Restore_Items; -use WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Empty; -use WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Apply_Coupon; -use WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Remove_Coupons; -use WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Add_Fee; -use WPGraphQL\Extensions\WooCommerce\Mutation\Order_Create; -use WPGraphQL\Extensions\WooCommerce\Mutation\Order_Update; -use WPGraphQL\Extensions\WooCommerce\Mutation\Order_Delete; -use WPGraphQL\Extensions\WooCommerce\Mutation\Order_Delete_Items; -use WPGraphQL\Extensions\WooCommerce\Mutation\Checkout; - /** * Class Type_Registry */ @@ -96,82 +25,82 @@ public static function add_actions() { */ public static function graphql_register_types() { // Enumerations. - Backorders::register(); - Catalog_Visibility::register(); - Countries::register(); - Customer_Connection_Orderby_Enum::register(); - Discount_Type::register(); - Manage_Stock::register(); - Order_Status::register(); - Product_Types::register(); - Stock_Status::register(); - Tax_Class::register(); - Tax_Status::register(); - WC_Connection_Orderby_Enum::register(); - Tax_Rate_Connection_Orderby_Enum::register(); - Pricing_Field_Format::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Backorders::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Catalog_Visibility::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Countries::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Customer_Connection_Orderby_Enum::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Discount_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Manage_Stock::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Order_Status::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Product_Types::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Stock_Status::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Class::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Status::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\WC_Connection_Orderby_Enum::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Tax_Rate_Connection_Orderby_Enum::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Pricing_Field_Format::register(); // InputObjects. - Customer_Address_Input::register(); - Product_Attribute_Input::register(); - WC_Connection_Orderby_Input::register(); - Tax_Rate_Connection_Orderby_Input::register(); - Fee_Line_Input::register(); - Line_Item_Input::register(); - Meta_Data_Input::register(); - Shipping_Line_Input::register(); - Create_Account_Input::register(); - Cart_Item_Quantity_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Customer_Address_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Product_Attribute_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\WC_Connection_Orderby_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Tax_Rate_Connection_Orderby_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Fee_Line_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Line_Item_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Meta_Data_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Shipping_Line_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Create_Account_Input::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Cart_Item_Quantity_Input::register(); // Objects. - Coupon_Type::register(); - Product_Type::register(); - Product_Variation_Type::register(); - Order_Type::register(); - Order_Item_Type::register(); - Refund_Type::register(); - Product_Attribute_Type::register(); - Product_Download_Type::register(); - Customer_Type::register(); - Customer_Address_Type::register(); - Tax_Rate_Type::register(); - Shipping_Method_Type::register(); - Cart_Type::register(); - Variation_Attribute_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Coupon_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Variation_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Order_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Order_Item_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Refund_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Attribute_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Download_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Customer_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Customer_Address_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Tax_Rate_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Shipping_Method_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Cart_Type::register(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Variation_Attribute_Type::register(); // Object fields. - Product_Category_Type::register_fields(); + \WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Category_Type::register_fields(); // Connections. - Posts::register_connections(); - WC_Terms::register_connections(); - Coupons::register_connections(); - Products::register_connections(); - Orders::register_connections(); - Order_Items::register_connections(); - Refunds::register_connections(); - Product_Attributes::register_connections(); - Variation_Attributes::register_connections(); - Customers::register_connections(); - Tax_Rates::register_connections(); - Shipping_Methods::register_connections(); - Cart_Items::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Posts::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\WC_Terms::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Coupons::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Products::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Orders::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Order_Items::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Refunds::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Product_Attributes::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Variation_Attributes::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Customers::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Tax_Rates::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Shipping_Methods::register_connections(); + \WPGraphQL\Extensions\WooCommerce\Connection\Cart_Items::register_connections(); // Mutations. - Customer_Register::register_mutation(); - Customer_Update::register_mutation(); - Cart_Add_Item::register_mutation(); - Cart_Update_Item_Quantities::register_mutation(); - Cart_Remove_Items::register_mutation(); - Cart_Restore_Items::register_mutation(); - Cart_Empty::register_mutation(); - Cart_Apply_Coupon::register_mutation(); - Cart_Remove_Coupons::register_mutation(); - Cart_Add_Fee::register_mutation(); - Order_Create::register_mutation(); - Order_Update::register_mutation(); - Order_Delete::register_mutation(); - Order_Delete_Items::register_mutation(); - Checkout::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Customer_Register::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Customer_Update::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Add_Item::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Update_Item_Quantities::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Remove_Items::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Restore_Items::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Empty::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Apply_Coupon::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Remove_Coupons::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Cart_Add_Fee::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Order_Create::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Order_Update::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Order_Delete::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Order_Delete_Items::register_mutation(); + \WPGraphQL\Extensions\WooCommerce\Mutation\Checkout::register_mutation(); } } diff --git a/includes/connection/class-posts.php b/includes/connection/class-posts.php index 1e1b79fca..e17bb55d1 100644 --- a/includes/connection/class-posts.php +++ b/includes/connection/class-posts.php @@ -9,9 +9,7 @@ namespace WPGraphQL\Extensions\WooCommerce\Connection; -use WPGraphQL\Data\DataSource; use WPGraphQL\Connection\PostObjects; -use WPGraphQL\Extensions\WooCommerce\Data\Factory; /** * Class - Posts diff --git a/includes/connection/class-wc-terms.php b/includes/connection/class-wc-terms.php index 5780f9bb3..90649df1a 100644 --- a/includes/connection/class-wc-terms.php +++ b/includes/connection/class-wc-terms.php @@ -10,9 +10,7 @@ namespace WPGraphQL\Extensions\WooCommerce\Connection; -use WPGraphQL\Data\DataSource; use WPGraphQL\Connection\TermObjects; -use WPGraphQL\Extensions\WooCommerce\Data\Factory; /** * Class - WC_Terms diff --git a/includes/data/class-factory.php b/includes/data/class-factory.php index 389a22b69..03ece6a85 100644 --- a/includes/data/class-factory.php +++ b/includes/data/class-factory.php @@ -13,7 +13,6 @@ use GraphQL\Deferred; use GraphQL\Error\UserError; use GraphQL\Type\Definition\ResolveInfo; -use GraphQLRelay\Relay; use WPGraphQL\AppContext; use WPGraphQL\Extensions\WooCommerce\Data\Connection\Coupon_Connection_Resolver; use WPGraphQL\Extensions\WooCommerce\Data\Connection\Customer_Connection_Resolver; diff --git a/includes/data/connection/class-coupon-connection-resolver.php b/includes/data/connection/class-coupon-connection-resolver.php index 67409895e..f43e05b1d 100644 --- a/includes/data/connection/class-coupon-connection-resolver.php +++ b/includes/data/connection/class-coupon-connection-resolver.php @@ -13,9 +13,7 @@ use GraphQL\Type\Definition\ResolveInfo; use WPGraphQL\AppContext; use WPGraphQL\Data\Connection\AbstractConnectionResolver; -use WPGraphQL\Extensions\WooCommerce\Model\Customer; use WPGraphQL\Extension\WooCommerce\Model\Order; -use WPGraphQL\Extensions\WooCommerce\Model\Refund; /** * Class Coupon_Connection_Resolver diff --git a/includes/data/connection/class-customer-connection-resolver.php b/includes/data/connection/class-customer-connection-resolver.php index 0a800e906..5e3795423 100644 --- a/includes/data/connection/class-customer-connection-resolver.php +++ b/includes/data/connection/class-customer-connection-resolver.php @@ -11,7 +11,6 @@ namespace WPGraphQL\Extensions\WooCommerce\Data\Connection; use GraphQL\Type\Definition\ResolveInfo; -use WPGraphQL\AppContext; use WPGraphQL\Data\Connection\AbstractConnectionResolver; use WPGraphQL\Extensions\WooCommerce\Model\Coupon; diff --git a/includes/data/connection/class-order-connection-resolver.php b/includes/data/connection/class-order-connection-resolver.php index 2eca0b44f..bc7c35d69 100644 --- a/includes/data/connection/class-order-connection-resolver.php +++ b/includes/data/connection/class-order-connection-resolver.php @@ -13,7 +13,6 @@ use GraphQL\Type\Definition\ResolveInfo; use WPGraphQL\AppContext; use WPGraphQL\Data\Connection\AbstractConnectionResolver; -use WPGraphQL\Extension\WooCommerce\Model\Order; use WPGraphQL\Extensions\WooCommerce\Model\Customer; /** diff --git a/includes/data/connection/class-post-connection-resolver.php b/includes/data/connection/class-post-connection-resolver.php index a90ce8347..cfc8ed81b 100644 --- a/includes/data/connection/class-post-connection-resolver.php +++ b/includes/data/connection/class-post-connection-resolver.php @@ -10,7 +10,6 @@ namespace WPGraphQL\Extensions\WooCommerce\Data\Connection; -use WPGraphQL\Data\Connection\PostObjectConnectionResolver; use GraphQL\Type\Definition\ResolveInfo; use WPGraphQL\AppContext; use WPGraphQL\Extensions\WooCommerce\Model\Product; diff --git a/includes/data/connection/class-product-connection-resolver.php b/includes/data/connection/class-product-connection-resolver.php index 90800f0c6..ac6efde4d 100644 --- a/includes/data/connection/class-product-connection-resolver.php +++ b/includes/data/connection/class-product-connection-resolver.php @@ -15,7 +15,6 @@ use WPGraphQL\AppContext; use WPGraphQL\Extensions\WooCommerce\Model\Coupon; use WPGraphQL\Extensions\WooCommerce\Model\Customer; -use WPGraphQL\Extensions\WooCommerce\Model\Order; use WPGraphQL\Extensions\WooCommerce\Model\Product; use WPGraphQL\Model\Term; diff --git a/includes/data/connection/class-variation-attribute-connection-resolver.php b/includes/data/connection/class-variation-attribute-connection-resolver.php index d8925f766..d4723698c 100644 --- a/includes/data/connection/class-variation-attribute-connection-resolver.php +++ b/includes/data/connection/class-variation-attribute-connection-resolver.php @@ -24,7 +24,7 @@ class Variation_Attribute_Connection_Resolver { * Returns data array from WC_Product_Attribute ArrayAccess object. * * @param WC_Product_Attribute $attrs - WC_Product_Attribute object. - * @param string $variation_id - ProductVariation Relay ID. + * @param string $parent_id - ProductVariation Relay ID. * * @return array */ diff --git a/includes/data/connection/class-wc-terms-connection-resolver.php b/includes/data/connection/class-wc-terms-connection-resolver.php index 03538b052..ecbca1628 100644 --- a/includes/data/connection/class-wc-terms-connection-resolver.php +++ b/includes/data/connection/class-wc-terms-connection-resolver.php @@ -10,7 +10,6 @@ namespace WPGraphQL\Extensions\WooCommerce\Data\Connection; -use WPGraphQL\Data\Connection\TermObjectConnectionResolver; use GraphQL\Type\Definition\ResolveInfo; use WPGraphQL\AppContext; use WPGraphQL\Extensions\WooCommerce\Model\Coupon; diff --git a/includes/model/class-customer.php b/includes/model/class-customer.php index f46f15541..2de864cb3 100644 --- a/includes/model/class-customer.php +++ b/includes/model/class-customer.php @@ -11,7 +11,6 @@ namespace WPGraphQL\Extensions\WooCommerce\Model; use GraphQLRelay\Relay; -use WPGraphQL\Data\DataSource; use WPGraphQL\Model\Model; /** diff --git a/includes/model/class-product-variation.php b/includes/model/class-product-variation.php index 492b85ec6..32761035c 100644 --- a/includes/model/class-product-variation.php +++ b/includes/model/class-product-variation.php @@ -11,7 +11,6 @@ namespace WPGraphQL\Extensions\WooCommerce\Model; use GraphQLRelay\Relay; -use WPGraphQL\Data\DataSource; /** * Class Product_Variation diff --git a/includes/model/trait-shop-manager-caps.php b/includes/model/trait-shop-manager-caps.php index 1c7fc727a..a385992a1 100644 --- a/includes/model/trait-shop-manager-caps.php +++ b/includes/model/trait-shop-manager-caps.php @@ -8,7 +8,6 @@ namespace WPGraphQL\Extensions\WooCommerce\Model; -use GraphQLRelay\Relay; /** * Trait Shop_Manager_Capabilities */ diff --git a/includes/mutation/class-cart-empty.php b/includes/mutation/class-cart-empty.php index ac0cbf900..8910253fb 100644 --- a/includes/mutation/class-cart-empty.php +++ b/includes/mutation/class-cart-empty.php @@ -58,9 +58,13 @@ public static function mutate_and_get_payload() { // Get WC_Cart instance. $cloned_cart = clone \WC()->cart; + do_action( 'woocommerce_graphql_before_empty_cart', $cloned_cart, $input, $context, $info ); + // Empty cart. \WC()->cart->empty_cart(); + do_action( 'woocommerce_graphql_after_empty_cart', $cloned_cart, $input, $context, $info ); + return array( 'cart' => $cloned_cart ); }; } diff --git a/includes/mutation/class-customer-register.php b/includes/mutation/class-customer-register.php index 19b338816..079fb55d5 100644 --- a/includes/mutation/class-customer-register.php +++ b/includes/mutation/class-customer-register.php @@ -11,10 +11,10 @@ use GraphQL\Error\UserError; use GraphQL\Type\Definition\ResolveInfo; use WPGraphQL\AppContext; -use WPGraphQL\Mutation\UserRegister; use WPGraphQL\Extensions\WooCommerce\Data\Mutation\Customer_Mutation; use WPGraphQL\Extensions\WooCommerce\Model\Customer; use WPGraphQL\Model\User; +use WPGraphQL\Mutation\UserRegister; /** * Class - Customer_Register diff --git a/includes/mutation/class-customer-update.php b/includes/mutation/class-customer-update.php index 4f71791d6..e43119c8c 100644 --- a/includes/mutation/class-customer-update.php +++ b/includes/mutation/class-customer-update.php @@ -11,10 +11,10 @@ use GraphQL\Error\UserError; use GraphQL\Type\Definition\ResolveInfo; use WPGraphQL\AppContext; -use WPGraphQL\Mutation\UserUpdate; use WPGraphQL\Extensions\WooCommerce\Data\Mutation\Customer_Mutation; use WPGraphQL\Extensions\WooCommerce\Model\Customer; use WPGraphQL\Model\User; +use WPGraphQL\Mutation\UserUpdate; /** * Class - Customer_Update diff --git a/includes/type/enum/class-product-types.php b/includes/type/enum/class-product-types.php index d5928a674..25854c1a9 100644 --- a/includes/type/enum/class-product-types.php +++ b/includes/type/enum/class-product-types.php @@ -8,8 +8,6 @@ namespace WPGraphQL\Extensions\WooCommerce\Type\WPEnum; -use WPGraphQL\Type\WPEnumType; - /** * Class Product_Types */ diff --git a/includes/type/enum/class-tax-class.php b/includes/type/enum/class-tax-class.php index 54d80efdd..179db8880 100644 --- a/includes/type/enum/class-tax-class.php +++ b/includes/type/enum/class-tax-class.php @@ -19,11 +19,11 @@ class Tax_Class { */ public static function register() { $values = array( - WPEnumType::get_safe_name( 'inherit cart' ) => array( + 'INHERIT_CART' => array( 'value' => 'inherit', 'description' => __( 'Inherits Tax class from cart', 'wp-graphql-woocommerce' ), ), - WPEnumType::get_safe_name( 'standard' ) => array( + 'STANDARD' => array( 'value' => '', 'description' => __( 'Standard Tax rate', 'wp-graphql-woocommerce' ), ), diff --git a/includes/type/object/class-cart-type.php b/includes/type/object/class-cart-type.php index 9d557a84f..2575bd0f9 100644 --- a/includes/type/object/class-cart-type.php +++ b/includes/type/object/class-cart-type.php @@ -12,9 +12,7 @@ use GraphQL\Error\UserError; use GraphQL\Type\Definition\ResolveInfo; -use GraphQLRelay\Relay; use WPGraphQL\AppContext; -use WPGraphQL\Type\WPObjectType; use WPGraphQL\Extensions\WooCommerce\Data\Factory; /** diff --git a/includes/type/object/class-product-attribute-type.php b/includes/type/object/class-product-attribute-type.php index e2c82ece4..aa6a5cb13 100644 --- a/includes/type/object/class-product-attribute-type.php +++ b/includes/type/object/class-product-attribute-type.php @@ -8,10 +8,6 @@ namespace WPGraphQL\Extensions\WooCommerce\Type\WPObject; -use WPGraphQL\Extensions\WooCommerce\Data\Factory; -use WPGraphQL\Data\DataSource; -use GraphQLRelay\Relay; - /** * Class Product_Attribute_Type */ diff --git a/includes/type/object/class-product-category-type.php b/includes/type/object/class-product-category-type.php index 93c2ba474..e5ab42d11 100644 --- a/includes/type/object/class-product-category-type.php +++ b/includes/type/object/class-product-category-type.php @@ -12,8 +12,6 @@ use WPGraphQL\AppContext; use WPGraphQL\Data\DataSource; -use WPGraphQL\Type\WPObjectType; -use WPGraphQL\Extensions\WooCommerce\Data\Factory; /** * Class - Product_Category_Type diff --git a/includes/type/object/class-product-download-type.php b/includes/type/object/class-product-download-type.php index 6d75656d5..1157d837e 100644 --- a/includes/type/object/class-product-download-type.php +++ b/includes/type/object/class-product-download-type.php @@ -10,10 +10,6 @@ namespace WPGraphQL\Extensions\WooCommerce\Type\WPObject; -use WPGraphQL\Extensions\WooCommerce\Data\Factory; -use WPGraphQL\Data\DataSource; -use GraphQLRelay\Relay; - /** * Class Product_Download_Type */ diff --git a/includes/type/object/class-product-variation-type.php b/includes/type/object/class-product-variation-type.php index c055c9d77..a395b25f0 100644 --- a/includes/type/object/class-product-variation-type.php +++ b/includes/type/object/class-product-variation-type.php @@ -15,9 +15,9 @@ use GraphQLRelay\Relay; use WPGraphQL\AppContext; use WPGraphQL\Data\DataSource; -use WPGraphQL\Type\WPObjectType; use WPGraphQL\Extensions\WooCommerce\Data\Factory; use WPGraphQL\Extensions\WooCommerce\Model\Product_Variation; +use WPGraphQL\Type\WPObjectType; /** * Class Product_Variation_Type diff --git a/includes/type/object/class-refund-type.php b/includes/type/object/class-refund-type.php index 06baf994d..621cdb567 100644 --- a/includes/type/object/class-refund-type.php +++ b/includes/type/object/class-refund-type.php @@ -15,9 +15,8 @@ use GraphQLRelay\Relay; use WPGraphQL\AppContext; use WPGraphQL\Data\DataSource; -use WPGraphQL\Type\WPObjectType; use WPGraphQL\Extensions\WooCommerce\Data\Factory; -use WPGraphQL\Extensions\WooCommerce\Model\Product_Variation; +use WPGraphQL\Type\WPObjectType; /** * Class Refund_Type @@ -103,11 +102,11 @@ public static function register() { ); $post_by_args = array( - 'id' => array( + 'id' => array( 'type' => 'ID', 'description' => __( 'Get the refund by its global ID', 'wp-graphql-woocommerce' ), ), - 'refundId' => array( + 'refundId' => array( 'type' => 'Int', 'description' => __( 'Get the refund by its database ID', 'wp-graphql-woocommerce' ), ), diff --git a/includes/type/object/class-shipping-method-type.php b/includes/type/object/class-shipping-method-type.php index bb4873610..debdd0c13 100644 --- a/includes/type/object/class-shipping-method-type.php +++ b/includes/type/object/class-shipping-method-type.php @@ -14,9 +14,9 @@ use GraphQL\Type\Definition\ResolveInfo; use GraphQLRelay\Relay; use WPGraphQL\AppContext; -use WPGraphQL\Type\WPObjectType; use WPGraphQL\Extensions\WooCommerce\Data\Factory; use WPGraphQL\Extensions\WooCommerce\Model\Shipping_Method; +use WPGraphQL\Type\WPObjectType; /** * Class Shipping_Method_Type diff --git a/includes/type/object/class-tax-rate-type.php b/includes/type/object/class-tax-rate-type.php index e060d3464..c2fee4a6d 100644 --- a/includes/type/object/class-tax-rate-type.php +++ b/includes/type/object/class-tax-rate-type.php @@ -14,9 +14,9 @@ use GraphQL\Type\Definition\ResolveInfo; use GraphQLRelay\Relay; use WPGraphQL\AppContext; -use WPGraphQL\Type\WPObjectType; use WPGraphQL\Extensions\WooCommerce\Data\Factory; use WPGraphQL\Extensions\WooCommerce\Model\Tax_Rate; +use WPGraphQL\Type\WPObjectType; /** * Class Tax_Rate_Type