-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Several product interfaces added. (#801)
- Loading branch information
Showing
12 changed files
with
665 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* Defines the fields for downloadable products. | ||
* | ||
* @package WPGraphQL\WooCommerce\Type\WPInterface | ||
* @since TBD | ||
*/ | ||
|
||
namespace WPGraphQL\WooCommerce\Type\WPInterface; | ||
|
||
use WPGraphQL\WooCommerce\Core_Schema_Filters as Core; | ||
|
||
/** | ||
* Class Downloadable_Products | ||
*/ | ||
class Downloadable_Products { | ||
/** | ||
* Registers the "DownloadableProducts" type | ||
* | ||
* @return void | ||
* @throws \Exception | ||
*/ | ||
public static function register_interface(): void { | ||
register_graphql_interface_type( | ||
'DownloadableProducts', | ||
[ | ||
'description' => __( 'Downloadable products.', 'wp-graphql-woocommerce' ), | ||
'interfaces' => [ 'Node' ], | ||
'fields' => self::get_fields(), | ||
'resolveType' => [ Core::class, 'resolve_product_type' ], | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Defines "DownloadableProducts" fields. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_fields() { | ||
return [ | ||
'id' => [ | ||
'type' => [ 'non_null' => 'ID' ], | ||
'description' => __( 'Product or variation global ID', 'wp-graphql-woocommerce' ), | ||
], | ||
'databaseId' => [ | ||
'type' => [ 'non_null' => 'Int' ], | ||
'description' => __( 'Product or variation ID', 'wp-graphql-woocommerce' ), | ||
], | ||
'virtual' => [ | ||
'type' => 'Boolean', | ||
'description' => __( 'Is product virtual?', 'wp-graphql-woocommerce' ), | ||
], | ||
'downloadExpiry' => [ | ||
'type' => 'Int', | ||
'description' => __( 'Download expiry', 'wp-graphql-woocommerce' ), | ||
], | ||
'downloadable' => [ | ||
'type' => 'Boolean', | ||
'description' => __( 'Is downloadable?', 'wp-graphql-woocommerce' ), | ||
], | ||
'downloadLimit' => [ | ||
'type' => 'Int', | ||
'description' => __( 'Download limit', 'wp-graphql-woocommerce' ), | ||
], | ||
'downloads' => [ | ||
'type' => [ 'list_of' => 'ProductDownload' ], | ||
'description' => __( 'Product downloads', 'wp-graphql-woocommerce' ), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* Defines the fields for manage product inventories. | ||
* | ||
* @package WPGraphQL\WooCommerce\Type\WPInterface | ||
* @since TBD | ||
*/ | ||
|
||
namespace WPGraphQL\WooCommerce\Type\WPInterface; | ||
|
||
use WPGraphQL\WooCommerce\Core_Schema_Filters as Core; | ||
|
||
/** | ||
* Class Inventoried_Products | ||
*/ | ||
class Inventoried_Products { | ||
/** | ||
* Registers the "InventoriedProducts" type | ||
* | ||
* @return void | ||
* @throws \Exception | ||
*/ | ||
public static function register_interface(): void { | ||
register_graphql_interface_type( | ||
'InventoriedProducts', | ||
[ | ||
'description' => __( 'Products with stock information.', 'wp-graphql-woocommerce' ), | ||
'interfaces' => [ 'Node' ], | ||
'fields' => self::get_fields(), | ||
'resolveType' => [ Core::class, 'resolve_product_type' ], | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Defines "InventoriedProducts" fields. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_fields() { | ||
return [ | ||
'id' => [ | ||
'type' => [ 'non_null' => 'ID' ], | ||
'description' => __( 'Product or variation global ID', 'wp-graphql-woocommerce' ), | ||
], | ||
'databaseId' => [ | ||
'type' => [ 'non_null' => 'Int' ], | ||
'description' => __( 'Product or variation ID', 'wp-graphql-woocommerce' ), | ||
], | ||
'manageStock' => [ | ||
'type' => 'Boolean', | ||
'description' => __( 'If product manage stock', 'wp-graphql-woocommerce' ), | ||
], | ||
'stockQuantity' => [ | ||
'type' => 'Int', | ||
'description' => __( 'Number of items available for sale', 'wp-graphql-woocommerce' ), | ||
], | ||
'backorders' => [ | ||
'type' => 'BackordersEnum', | ||
'description' => __( 'Product backorders status', 'wp-graphql-woocommerce' ), | ||
], | ||
'soldIndividually' => [ | ||
'type' => 'Boolean', | ||
'description' => __( 'If should be sold individually', 'wp-graphql-woocommerce' ), | ||
], | ||
'backordersAllowed' => [ | ||
'type' => 'Boolean', | ||
'description' => __( 'Can product be backordered?', 'wp-graphql-woocommerce' ), | ||
], | ||
'stockStatus' => [ | ||
'type' => 'StockStatusEnum', | ||
'description' => __( 'Product stock status', 'wp-graphql-woocommerce' ), | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
includes/type/interface/class-products-with-dimensions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
/** | ||
* Defines the fields for physical products. | ||
* | ||
* @package WPGraphQL\WooCommerce\Type\WPInterface | ||
* @since TBD | ||
*/ | ||
|
||
namespace WPGraphQL\WooCommerce\Type\WPInterface; | ||
|
||
use WPGraphQL\WooCommerce\Core_Schema_Filters as Core; | ||
|
||
/** | ||
* Class Products_With_Dimensions | ||
*/ | ||
class Products_With_Dimensions { | ||
/** | ||
* Registers the "ProductsWithDimensions" type | ||
* | ||
* @return void | ||
* @throws \Exception | ||
*/ | ||
public static function register_interface(): void { | ||
register_graphql_interface_type( | ||
'ProductsWithDimensions', | ||
[ | ||
'description' => __( 'Physical products.', 'wp-graphql-woocommerce' ), | ||
'interfaces' => [ 'Node' ], | ||
'fields' => self::get_fields(), | ||
'resolveType' => [ Core::class, 'resolve_product_type' ], | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Defines "ProductsWithDimensions" fields. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_fields() { | ||
return [ | ||
'id' => [ | ||
'type' => [ 'non_null' => 'ID' ], | ||
'description' => __( 'Product or variation global ID', 'wp-graphql-woocommerce' ), | ||
], | ||
'databaseId' => [ | ||
'type' => [ 'non_null' => 'Int' ], | ||
'description' => __( 'Product or variation ID', 'wp-graphql-woocommerce' ), | ||
], | ||
'weight' => [ | ||
'type' => 'String', | ||
'description' => __( 'Product\'s weight', 'wp-graphql-woocommerce' ), | ||
], | ||
'length' => [ | ||
'type' => 'String', | ||
'description' => __( 'Product\'s length', 'wp-graphql-woocommerce' ), | ||
], | ||
'width' => [ | ||
'type' => 'String', | ||
'description' => __( 'Product\'s width', 'wp-graphql-woocommerce' ), | ||
], | ||
'height' => [ | ||
'type' => 'String', | ||
'description' => __( 'Product\'s height', 'wp-graphql-woocommerce' ), | ||
], | ||
'shippingClassId' => [ | ||
'type' => 'Int', | ||
'description' => __( 'shipping class ID', 'wp-graphql-woocommerce' ), | ||
], | ||
'shippingRequired' => [ | ||
'type' => 'Boolean', | ||
'description' => __( 'Does product need to be shipped?', 'wp-graphql-woocommerce' ), | ||
], | ||
'shippingTaxable' => [ | ||
'type' => 'Boolean', | ||
'description' => __( 'Is product shipping taxable?', 'wp-graphql-woocommerce' ), | ||
], | ||
]; | ||
} | ||
} |
Oops, something went wrong.