forked from wp-graphql/wp-graphql-woocommerce
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request wp-graphql#42 from kidunot89/release-v0.0.3-beta
Release v0.0.3 beta
- Loading branch information
Showing
51 changed files
with
2,604 additions
and
4,179 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Connection - Cart_Items | ||
* | ||
* Registers connections to CartItem | ||
* | ||
* @package WPGraphQL\Extensions\WooCommerce\Connection | ||
* @since 0.0.3 | ||
*/ | ||
|
||
namespace WPGraphQL\Extensions\WooCommerce\Connection; | ||
|
||
use WPGraphQL\Extensions\WooCommerce\Data\Factory; | ||
|
||
/** | ||
* Class - Cart_Items | ||
*/ | ||
class Cart_Items { | ||
/** | ||
* Registers the various connections from other Types to CartItem | ||
*/ | ||
public static function register_connections() { | ||
// From Cart. | ||
register_graphql_connection( self::get_connection_config() ); | ||
} | ||
|
||
/** | ||
* Given an array of $args, this returns the connection config, merging the provided args | ||
* with the defaults | ||
* | ||
* @access public | ||
* @param array $args - Connection configuration. | ||
* | ||
* @return array | ||
*/ | ||
public static function get_connection_config( $args = [] ) { | ||
$defaults = array( | ||
'fromType' => 'Cart', | ||
'toType' => 'CartItem', | ||
'fromFieldName' => 'contents', | ||
'connectionArgs' => self::get_connection_args(), | ||
'resolve' => function ( $source, $args, $context, $info ) { | ||
return Factory::resolve_cart_item_connection( $source, $args, $context, $info ); | ||
}, | ||
); | ||
return array_merge( $defaults, $args ); | ||
} | ||
|
||
/** | ||
* Returns array of where args | ||
* | ||
* @return array | ||
*/ | ||
public static function get_connection_args() { | ||
return array( | ||
'needShipping' => array( | ||
'type' => 'Boolean', | ||
'description' => __( 'Limit results to cart item that require shipping', '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
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
Oops, something went wrong.