2019-03-21 21:43:24 -04:00
<? php
2019-03-22 16:36:34 -04:00
/**
2024-11-06 19:23:36 -05:00
* Registers WPGraphQL for WooCommerce types to the schema.
2019-03-22 16:36:34 -04:00
*
2019-10-25 19:13:36 -04:00
* @package \WPGraphQL\WooCommerce
2019-03-22 16:36:34 -04:00
* @since 0.0.1
*/
2019-03-21 21:43:24 -04:00
2019-10-25 19:13:36 -04:00
namespace WPGraphQL\WooCommerce ;
2019-03-21 21:43:24 -04:00
/**
2019-07-11 16:43:36 -04:00
* Class Type_Registry
2019-03-21 21:43:24 -04:00
*/
2019-07-11 16:43:36 -04:00
class Type_Registry {
2019-03-21 21:43:24 -04:00
/**
2024-11-06 19:23:36 -05:00
* Registers WPGraphQL for WooCommerce types, connections, unions, and mutations to GraphQL schema
2019-10-24 13:56:12 -04:00
*
2023-06-13 23:17:02 +03:00
* @return void
2019-03-21 21:43:24 -04:00
*/
2023-06-13 23:17:02 +03:00
public function init () {
2023-05-22 13:43:10 -04:00
/**
* Enumerations.
*/
2026-03-27 16:32:30 -04:00
Type\WPEnum\Attribute_Operator_Enum :: register ();
2022-08-26 14:53:36 -04:00
Type\WPEnum\Backorders :: register ();
2026-03-27 16:32:30 -04:00
Type\WPEnum\Cart_Error_Type :: register ();
Type\WPEnum\Cart_Notice_Type :: register ();
2022-08-26 14:53:36 -04:00
Type\WPEnum\Catalog_Visibility :: register ();
Type\WPEnum\Countries :: register ();
2026-03-27 16:32:30 -04:00
Type\WPEnum\Currency_Enum :: register ();
2022-08-26 14:53:36 -04:00
Type\WPEnum\Customer_Connection_Orderby_Enum :: register ();
Type\WPEnum\Discount_Type :: register ();
2026-03-27 16:32:30 -04:00
Type\WPEnum\Id_Type_Enums :: register ();
2022-08-26 14:53:36 -04:00
Type\WPEnum\Manage_Stock :: register ();
Type\WPEnum\Order_Status :: register ();
2026-03-27 16:32:30 -04:00
Type\WPEnum\Orders_Orderby_Enum :: register ();
Type\WPEnum\Post_Type_Orderby_Enum :: register ();
Type\WPEnum\Pricing_Field_Format :: register ();
Type\WPEnum\Product_Attribute_Enum :: register ();
2022-08-26 14:53:36 -04:00
Type\WPEnum\Product_Attribute_Types :: register ();
2026-03-27 16:32:30 -04:00
Type\WPEnum\Product_Attributes_Connection_Orderby_Enum :: register ();
2022-08-26 14:53:36 -04:00
Type\WPEnum\Product_Category_Display :: register ();
2026-03-27 16:32:30 -04:00
Type\WPEnum\Product_Taxonomy :: register ();
Type\WPEnum\Product_Types :: register ();
Type\WPEnum\Products_Orderby_Enum :: register ();
Type\WPEnum\Shipping_Location_Type_Enum :: register ();
2022-08-26 14:53:36 -04:00
Type\WPEnum\Stock_Status :: register ();
Type\WPEnum\Tax_Class :: register ();
Type\WPEnum\Tax_Rate_Connection_Orderby_Enum :: register ();
2026-03-27 16:32:30 -04:00
Type\WPEnum\Tax_Status :: register ();
2022-08-26 14:53:36 -04:00
Type\WPEnum\Taxonomy_Operator :: register ();
2024-05-17 00:03:10 -04:00
Type\WPEnum\WC_Setting_Type_Enum :: register ();
2019-04-10 12:26:37 -04:00
2023-05-22 13:43:10 -04:00
/**
* InputObjects.
*/
2022-08-26 14:53:36 -04:00
Type\WPInputObject\Cart_Item_Input :: register ();
2026-03-27 16:32:30 -04:00
Type\WPInputObject\Cart_Item_Quantity_Input :: register ();
Type\WPInputObject\Collection_Stats_Query_Input :: register ();
Type\WPInputObject\Collection_Stats_Where_Args :: register ();
Type\WPInputObject\Create_Account_Input :: register ();
2022-08-26 14:53:36 -04:00
Type\WPInputObject\Customer_Address_Input :: register ();
2026-03-18 16:59:08 -04:00
Type\WPInputObject\Fee_Input :: register ();
2022-08-26 14:53:36 -04:00
Type\WPInputObject\Fee_Line_Input :: register ();
Type\WPInputObject\Line_Item_Input :: register ();
Type\WPInputObject\Meta_Data_Input :: register ();
Type\WPInputObject\Orderby_Inputs :: register ();
2023-09-23 03:50:17 -04:00
Type\WPInputObject\Product_Attribute_Filter_Input :: register ();
2026-03-27 16:32:30 -04:00
Type\WPInputObject\Product_Attribute_Input :: register ();
2024-05-16 21:27:54 -04:00
Type\WPInputObject\Product_Attribute_Query_Input :: register ();
2026-03-20 13:31:13 -04:00
Type\WPInputObject\Product_Attributes_Input :: register ();
Type\WPInputObject\Product_Dimensions_Input :: register ();
Type\WPInputObject\Product_Download_Input :: register ();
Type\WPInputObject\Product_Image_Input :: register ();
2026-03-27 16:32:30 -04:00
Type\WPInputObject\Product_Taxonomy_Filter_Input :: register ();
Type\WPInputObject\Product_Taxonomy_Input :: register ();
Type\WPInputObject\Shipping_Line_Input :: register ();
Type\WPInputObject\Shipping_Location_Input :: register ();
Type\WPInputObject\Tax_Rate_Connection_Orderby_Input :: register ();
Type\WPInputObject\WC_Setting_Input :: register ();
2019-03-21 21:43:24 -04:00
2023-05-22 13:43:10 -04:00
/**
* Interfaces.
*/
2023-06-13 23:17:02 +03:00
Type\WPInterface\Attribute :: register_interface ();
Type\WPInterface\Cart_Error :: register_interface ();
2023-09-13 12:35:42 -04:00
Type\WPInterface\Cart_Item :: register_interface ();
2023-09-15 21:03:55 -04:00
Type\WPInterface\Downloadable_Product :: register_interface ();
Type\WPInterface\Inventoried_Product :: register_interface ();
2026-03-27 16:32:30 -04:00
Type\WPInterface\Payment_Token_Interface :: register_interface ();
Type\WPInterface\Product :: register_interface ();
Type\WPInterface\Product_Attribute :: register_interface ();
Type\WPInterface\Product_Union :: register_interface ();
Type\WPInterface\Product_Variation :: register_interface ();
Type\WPInterface\Product_With_Attributes :: register_interface ();
2023-09-15 21:03:55 -04:00
Type\WPInterface\Product_With_Dimensions :: register_interface ();
Type\WPInterface\Product_With_Pricing :: register_interface ();
Type\WPInterface\Product_With_Variations :: register_interface ();
2026-03-27 16:32:30 -04:00
Type\WPInterface\WC_Setting :: register_interface ();
2019-10-24 22:11:04 -04:00
2023-05-22 13:43:10 -04:00
/**
* Objects.
*/
2022-08-26 14:53:36 -04:00
Type\WPObject\Cart_Error_Types :: register ();
2026-03-18 17:51:27 -04:00
Type\WPObject\Cart_Notice :: register ();
2026-03-27 16:32:30 -04:00
Type\WPObject\Cart_Type :: register ();
Type\WPObject\Collection_Stats_Type :: register ();
Type\WPObject\Country_State_Type :: register ();
Type\WPObject\Coupon_Type :: register ();
Type\WPObject\Customer_Address_Type :: register ();
Type\WPObject\Customer_Type :: register ();
Type\WPObject\Downloadable_Item_Type :: register ();
Type\WPObject\Meta_Data_Type :: register ();
Type\WPObject\Order_Item_Type :: register ();
Type\WPObject\Order_Note_Type :: register ();
Type\WPObject\Order_Type :: register ();
Type\WPObject\Payment_Gateway_Type :: register ();
Type\WPObject\Payment_Token_Types :: register ();
2026-03-20 13:31:13 -04:00
Type\WPObject\Product_Attribute_Object_Type :: register ();
Type\WPObject\Product_Attribute_Term_Object_Type :: register ();
2026-03-27 16:32:30 -04:00
Type\WPObject\Product_Attribute_Types :: register ();
Type\WPObject\Product_Download_Type :: register ();
Type\WPObject\Product_Types :: register ();
Type\WPObject\Refund_Type :: register ();
Type\WPObject\Shipping_Location_Type :: register ();
Type\WPObject\Shipping_Method_Type :: register ();
Type\WPObject\Shipping_Package_Type :: register ();
Type\WPObject\Shipping_Rate_Type :: register ();
Type\WPObject\Shipping_Zone_Type :: register ();
Type\WPObject\Simple_Attribute_Type :: register ();
Type\WPObject\Tax_Class_Type :: register ();
Type\WPObject\Tax_Rate_Type :: register ();
Type\WPObject\Variation_Attribute_Type :: register ();
Type\WPObject\WC_Setting_Group_Type :: register ();
Type\WPObject\WC_Setting_Type :: register ();
2019-03-24 20:22:05 -04:00
2023-05-22 13:43:10 -04:00
/**
* Object fields.
*/
2026-06-30 07:36:19 -07:00
Type\WPObject\Product_Brand_Type :: register_fields ();
2022-08-26 14:53:36 -04:00
Type\WPObject\Product_Category_Type :: register_fields ();
Type\WPObject\Root_Query :: register_fields ();
2019-07-09 23:01:09 -04:00
2023-05-22 13:43:10 -04:00
// Register the following fields only if "disable_ql_session_handler" option is not on.
2026-03-27 16:32:30 -04:00
$ql_session_handled_enabled = ! wc_graphql_is_session_handler_disabled ();
2023-05-22 13:43:10 -04:00
if ( $ql_session_handled_enabled ) {
Type\WPObject\Customer_Type :: register_session_handler_fields ();
}
// Register the following fields only if "disable_ql_session_handler" option is not "on" and some fields under the "enable_authorizing_url_fields" option are "selected".
2026-03-27 16:32:30 -04:00
$enabled_url_fields = wc_graphql_enabled_authorizing_url_fields ();
2023-05-22 13:43:10 -04:00
if ( $ql_session_handled_enabled && ! empty ( $enabled_url_fields ) ) {
Type\WPObject\Customer_Type :: register_authorizing_url_fields ( array_keys ( $enabled_url_fields ) );
}
/**
* Connections.
*/
2022-08-26 14:53:36 -04:00
Connection\Comments :: register_connections ();
Connection\Coupons :: register_connections ();
Connection\Customers :: register_connections ();
2026-03-27 16:32:30 -04:00
Connection\Orders :: register_connections ();
2022-08-26 14:53:36 -04:00
Connection\Payment_Gateways :: register_connections ();
2026-03-27 16:32:30 -04:00
Connection\Posts :: register_connections ();
Connection\Product_Attributes :: register_connections ();
Connection\Products :: register_connections ();
Connection\Shipping_Methods :: register_connections ();
2024-05-17 00:03:10 -04:00
Connection\Shipping_Zones :: register_connections ();
Connection\Tax_Classes :: register_connections ();
2026-03-27 16:32:30 -04:00
Connection\Tax_Rates :: register_connections ();
Connection\WC_Terms :: register_connections ();
2019-05-01 22:01:34 -04:00
2023-05-22 13:43:10 -04:00
/**
* Mutations.
*/
2026-03-20 13:31:13 -04:00
Mutation\Cart_Add_Fee :: register_mutation ();
2022-08-26 14:53:36 -04:00
Mutation\Cart_Add_Item :: register_mutation ();
Mutation\Cart_Add_Items :: register_mutation ();
Mutation\Cart_Apply_Coupon :: register_mutation ();
2026-03-20 13:31:13 -04:00
Mutation\Cart_Empty :: register_mutation ();
2022-08-26 14:53:36 -04:00
Mutation\Cart_Fill :: register_mutation ();
2026-03-20 13:31:13 -04:00
Mutation\Cart_Remove_Coupons :: register_mutation ();
2026-03-27 16:32:30 -04:00
Mutation\Cart_Remove_Items :: register_mutation ();
2026-03-20 13:31:13 -04:00
Mutation\Cart_Restore_Items :: register_mutation ();
Mutation\Cart_Update_Item_Quantities :: register_mutation ();
Mutation\Cart_Update_Shipping_Method :: register_mutation ();
Mutation\Checkout :: register_mutation ();
Mutation\Coupon_Create :: register_mutation ();
Mutation\Coupon_Delete :: register_mutation ();
2026-03-27 16:32:30 -04:00
Mutation\Coupon_Update :: register_mutation ();
2026-03-20 13:31:13 -04:00
Mutation\Customer_Register :: register_mutation ();
Mutation\Customer_Update :: register_mutation ();
2022-08-26 14:53:36 -04:00
Mutation\Order_Create :: register_mutation ();
Mutation\Order_Delete :: register_mutation ();
Mutation\Order_Delete_Items :: register_mutation ();
2025-10-11 16:29:36 -04:00
Mutation\Order_Note_Create :: register_mutation ();
Mutation\Order_Note_Delete :: register_mutation ();
2026-03-27 16:32:30 -04:00
Mutation\Order_Update :: register_mutation ();
2023-04-20 17:33:58 -04:00
Mutation\Payment_Method_Delete :: register_mutation ();
Mutation\Payment_Method_Set_Default :: register_mutation ();
2026-03-20 13:31:13 -04:00
Mutation\Product_Attribute_Create :: register_mutation ();
Mutation\Product_Attribute_Delete :: register_mutation ();
Mutation\Product_Attribute_Term_Create :: register_mutation ();
Mutation\Product_Attribute_Term_Delete :: register_mutation ();
2026-03-27 16:32:30 -04:00
Mutation\Product_Attribute_Term_Update :: register_mutation ();
Mutation\Product_Attribute_Update :: register_mutation ();
Mutation\Product_Category_Create :: register ();
Mutation\Product_Category_Update :: register ();
2026-03-20 13:31:13 -04:00
Mutation\Product_Create :: register_mutation ();
Mutation\Product_Delete :: register_mutation ();
2026-03-27 16:32:30 -04:00
Mutation\Product_Update :: register_mutation ();
2026-03-20 13:31:13 -04:00
Mutation\Product_Variation_Create :: register_mutation ();
Mutation\Product_Variation_Delete :: register_mutation ();
2026-03-27 16:32:30 -04:00
Mutation\Product_Variation_Update :: register_mutation ();
2026-03-31 10:24:01 -04:00
Mutation\Refund_Create :: register_mutation ();
Mutation\Refund_Delete :: register_mutation ();
2026-03-27 16:32:30 -04:00
Mutation\Review_Delete_Restore :: register_mutation ();
Mutation\Review_Update :: register_mutation ();
Mutation\Review_Write :: register_mutation ();
2026-03-20 13:31:13 -04:00
Mutation\Session_Delete :: register_mutation ();
Mutation\Session_Update :: register_mutation ();
2026-03-27 16:32:30 -04:00
Mutation\Setting_Update :: register_mutation ();
Mutation\Settings_Update :: register_mutation ();
2024-05-17 00:03:10 -04:00
Mutation\Shipping_Zone_Create :: register_mutation ();
Mutation\Shipping_Zone_Delete :: register_mutation ();
Mutation\Shipping_Zone_Locations_Clear :: register_mutation ();
Mutation\Shipping_Zone_Locations_Update :: register_mutation ();
Mutation\Shipping_Zone_Method_Add :: register_mutation ();
Mutation\Shipping_Zone_Method_Remove :: register_mutation ();
Mutation\Shipping_Zone_Method_Update :: register_mutation ();
Mutation\Shipping_Zone_Update :: register_mutation ();
Mutation\Tax_Class_Create :: register_mutation ();
Mutation\Tax_Class_Delete :: register_mutation ();
Mutation\Tax_Rate_Create :: register_mutation ();
Mutation\Tax_Rate_Delete :: register_mutation ();
Mutation\Tax_Rate_Update :: register_mutation ();
2019-03-21 21:43:24 -04:00
}
}