mirror of
https://github.com/wp-graphql/wp-graphql-woocommerce.git
synced 2026-08-14 12:53:44 +02:00
Merge pull request #28 from kidunot89/feature/order-item
Order items, TaxRate, and ShippingMethod
This commit is contained in:
@@ -54,3 +54,25 @@ function wc_graphql_ends_with( $haystack, $needle ) {
|
||||
|
||||
return ( substr( $haystack, -$length ) === $needle );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns formatted array of tax statement objects.
|
||||
*
|
||||
* @param array $raw_taxes - array of raw taxes object from WC_Order_Item crud objects.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function wc_graphql_map_tax_statements( $raw_taxes ) {
|
||||
$taxes = array();
|
||||
foreach ( $raw_taxes as $field => $values ) {
|
||||
foreach ( $values as $id => $amount ) {
|
||||
if ( empty( $taxes[ $id ] ) ) {
|
||||
$taxes[ $id ] = array();
|
||||
}
|
||||
$taxes[ $id ]['ID'] = $id;
|
||||
$taxes[ $id ][ $field ] = $amount;
|
||||
}
|
||||
}
|
||||
|
||||
return array_values( $taxes );
|
||||
}
|
||||
|
||||
@@ -15,11 +15,15 @@ use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Catalog_Visibility;
|
||||
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Discount_Type;
|
||||
use WPGraphQL\Extensions\WooCommerce\Type\WPEnum\Manage_Stock;
|
||||
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\WPInputObject\WC_Connection_Orderby_Input;
|
||||
use WPGraphQL\Extensions\WooCommerce\Type\WPInputObject\Tax_Rate_Connection_Orderby_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;
|
||||
@@ -28,15 +32,21 @@ use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Download_Type;
|
||||
use WPGraphQL\Extensions\WooCommerce\Type\WPObject\Product_Rating_Counter_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\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\Product_Gallery;
|
||||
use WPGraphQL\Extensions\WooCommerce\Connection\Customers;
|
||||
use WPGraphQL\Extensions\WooCommerce\Connection\Tax_Rates;
|
||||
use WPGraphQL\Extensions\WooCommerce\Connection\Shipping_Methods;
|
||||
|
||||
/**
|
||||
* Class Actions
|
||||
*/
|
||||
@@ -65,23 +75,29 @@ class Actions {
|
||||
Discount_Type::register();
|
||||
Manage_Stock::register();
|
||||
Stock_Status::register();
|
||||
Tax_Class::register();
|
||||
Tax_Status::register();
|
||||
WC_Connection_Orderby_Enum::register();
|
||||
Tax_Rate_Connection_Orderby_Enum::register();
|
||||
|
||||
// InputObjects.
|
||||
WC_Connection_Orderby_Input::register();
|
||||
Tax_Rate_Connection_Orderby_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();
|
||||
Product_Rating_Counter_Type::register();
|
||||
Customer_Type::register();
|
||||
Customer_Address_Type::register();
|
||||
Tax_Rate_Type::register();
|
||||
Shipping_Method_Type::register();
|
||||
|
||||
// Connections.
|
||||
Posts::register_connections();
|
||||
@@ -89,8 +105,11 @@ class Actions {
|
||||
Coupons::register_connections();
|
||||
Products::register_connections();
|
||||
Orders::register_connections();
|
||||
Order_Items::register_connections();
|
||||
Refunds::register_connections();
|
||||
Product_Attributes::register_connections();
|
||||
Customers::register_connections();
|
||||
Tax_Rates::register_connections();
|
||||
Shipping_Methods::register_connections();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
/**
|
||||
* Connection - Order_Items
|
||||
*
|
||||
* Registers connections to OrderItem
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Connection
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Connection;
|
||||
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Factory;
|
||||
|
||||
/**
|
||||
* Class - Order_Items
|
||||
*/
|
||||
class Order_Items {
|
||||
/**
|
||||
* Registers connection
|
||||
*/
|
||||
public static function register_connections() {
|
||||
// From Order.
|
||||
register_graphql_connection( self::get_connection_config() );
|
||||
register_graphql_connection(
|
||||
self::get_connection_config(
|
||||
array(
|
||||
'toType' => 'TaxLine',
|
||||
'fromFieldName' => 'taxLines',
|
||||
)
|
||||
)
|
||||
);
|
||||
register_graphql_connection(
|
||||
self::get_connection_config(
|
||||
array(
|
||||
'toType' => 'ShippingLine',
|
||||
'fromFieldName' => 'shippingLines',
|
||||
)
|
||||
)
|
||||
);
|
||||
register_graphql_connection(
|
||||
self::get_connection_config(
|
||||
array(
|
||||
'toType' => 'FeeLine',
|
||||
'fromFieldName' => 'feeLines',
|
||||
)
|
||||
)
|
||||
);
|
||||
register_graphql_connection(
|
||||
self::get_connection_config(
|
||||
array(
|
||||
'toType' => 'FeeLine',
|
||||
'toType' => 'CouponLine',
|
||||
'fromFieldName' => 'couponLines',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// From Refund.
|
||||
register_graphql_connection( self::get_connection_config( array( 'fromType' => 'Refund' ) ) );
|
||||
register_graphql_connection(
|
||||
self::get_connection_config(
|
||||
array(
|
||||
'fromType' => 'Refund',
|
||||
'toType' => 'TaxLine',
|
||||
'fromFieldName' => 'taxLines',
|
||||
)
|
||||
)
|
||||
);
|
||||
register_graphql_connection(
|
||||
self::get_connection_config(
|
||||
array(
|
||||
'fromType' => 'Refund',
|
||||
'toType' => 'ShippingLine',
|
||||
'fromFieldName' => 'shippingLines',
|
||||
)
|
||||
)
|
||||
);
|
||||
register_graphql_connection(
|
||||
self::get_connection_config(
|
||||
array(
|
||||
'fromType' => 'Refund',
|
||||
'toType' => 'FeeLine',
|
||||
'fromFieldName' => 'feeLines',
|
||||
)
|
||||
)
|
||||
);
|
||||
register_graphql_connection(
|
||||
self::get_connection_config(
|
||||
array(
|
||||
'fromType' => 'Refund',
|
||||
'toType' => 'CouponLine',
|
||||
'fromFieldName' => 'couponLines',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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' => 'Order',
|
||||
'toType' => 'LineItem',
|
||||
'fromFieldName' => 'lineItems',
|
||||
'connectionArgs' => array(),
|
||||
'resolveNode' => function( $item, $args, $context, $info ) {
|
||||
return Factory::resolve_order_item( $item );
|
||||
},
|
||||
'resolve' => function ( $source, $args, $context, $info ) {
|
||||
return Factory::resolve_order_item_connection( $source, $args, $context, $info );
|
||||
},
|
||||
);
|
||||
return array_merge( $defaults, $args );
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class Refunds extends WC_Connection {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_connection_config( $args = [] ) {
|
||||
public static function get_connection_config( $args = array() ) {
|
||||
$defaults = array(
|
||||
'fromType' => 'RootQuery',
|
||||
'toType' => 'Refund',
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Connection - Shipping_Methods
|
||||
*
|
||||
* Registers connections to ShippingMethod
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Connection
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Connection;
|
||||
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Factory;
|
||||
|
||||
/**
|
||||
* Class - Shipping_Methods
|
||||
*/
|
||||
class Shipping_Methods {
|
||||
/**
|
||||
* Registers the various connections from other Types to TaxRate
|
||||
*/
|
||||
public static function register_connections() {
|
||||
// From RootQuery.
|
||||
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 = array() ) {
|
||||
$defaults = array(
|
||||
'fromType' => 'RootQuery',
|
||||
'toType' => 'ShippingMethod',
|
||||
'fromFieldName' => 'shippingMethods',
|
||||
'connectionArgs' => array(),
|
||||
'resolveNode' => function( $id, $args, $context, $info ) {
|
||||
return Factory::resolve_shipping_method( $id );
|
||||
},
|
||||
'resolve' => function ( $source, $args, $context, $info ) {
|
||||
return Factory::resolve_shipping_method_connection( $source, $args, $context, $info );
|
||||
},
|
||||
);
|
||||
return array_merge( $defaults, $args );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Connection - Tax_Rates
|
||||
*
|
||||
* Registers connections to TaxRate
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Connection
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Connection;
|
||||
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Factory;
|
||||
|
||||
/**
|
||||
* Class - Tax_Rates
|
||||
*/
|
||||
class Tax_Rates {
|
||||
/**
|
||||
* Registers the various connections from other Types to TaxRate
|
||||
*/
|
||||
public static function register_connections() {
|
||||
// From RootQuery.
|
||||
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 = array() ) {
|
||||
$defaults = array(
|
||||
'fromType' => 'RootQuery',
|
||||
'toType' => 'TaxRate',
|
||||
'fromFieldName' => 'taxRates',
|
||||
'connectionArgs' => self::get_connection_args(),
|
||||
'resolveNode' => function( $id, $args, $context, $info ) {
|
||||
return Factory::resolve_tax_rate( $id );
|
||||
},
|
||||
'resolve' => function ( $source, $args, $context, $info ) {
|
||||
return Factory::resolve_tax_rate_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(
|
||||
'class' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Sort by tax class', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'orderby' => array(
|
||||
'type' => array( 'list_of' => 'TaxRateConnectionOrderbyInput' ),
|
||||
'description' => __( 'What paramater to use to order the objects by.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,18 @@ use WPGraphQL\AppContext;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Coupon_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Customer_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Order_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Order_Item_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Product_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Product_Attribute_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Product_Download_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Refund_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Tax_Rate_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\Shipping_Method_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\WC_Posts_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Connection\WC_Terms_Connection_Resolver;
|
||||
use WPGraphQL\Extensions\WooCommerce\Model\Order_Item;
|
||||
use WPGraphQL\Extensions\WooCommerce\Model\Tax_Rate;
|
||||
use WPGraphQL\Extensions\WooCommerce\Model\Shipping_Method;
|
||||
|
||||
/**
|
||||
* Class Factory
|
||||
@@ -75,6 +81,90 @@ class Factory {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the order item Model for the order item.
|
||||
*
|
||||
* @param int $item - order item crud object instance.
|
||||
*
|
||||
* @return Order_Item
|
||||
* @access public
|
||||
* @throws UserError Invalid object.
|
||||
*/
|
||||
public static function resolve_order_item( $item ) {
|
||||
/**
|
||||
* If $id is an instance of WC_Order_Item
|
||||
*/
|
||||
if ( is_a( $item, \WC_Order_Item::class ) ) {
|
||||
return new Order_Item( $item );
|
||||
} else {
|
||||
throw new UserError( __( 'Object provided to order item resolver is an invalid type', 'wp-graphql-woocommerce' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tax rate Model for the tax rate ID.
|
||||
*
|
||||
* @param int $id - Tax rate ID.
|
||||
*
|
||||
* @return Tax_Rate
|
||||
* @access public
|
||||
* @throws UserError Invalid object.
|
||||
*/
|
||||
public static function resolve_tax_rate( $id ) {
|
||||
global $wpdb;
|
||||
|
||||
$rate = \WC_Tax::_get_tax_rate( $id, OBJECT );
|
||||
if ( ! \is_wp_error( $rate ) && ! empty( $rate ) ) {
|
||||
// Get locales from a tax rate.
|
||||
$locales = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT location_code, location_type
|
||||
FROM {$wpdb->prefix}woocommerce_tax_rate_locations
|
||||
WHERE tax_rate_id = %d",
|
||||
$rate->tax_rate_id
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( $locales as $locale ) {
|
||||
if ( empty( $rate->{'tax_rate_' . $locale->location_type} ) ) {
|
||||
$rate->{'tax_rate_' . $locale->location_type} = array();
|
||||
}
|
||||
$rate->{'tax_rate_' . $locale->location_type}[] = $locale->location_code;
|
||||
}
|
||||
|
||||
return new Tax_Rate( $rate );
|
||||
} else {
|
||||
throw new UserError(
|
||||
/* translators: tax rate not found error message */
|
||||
sprintf( __( 'No Tax Rate assigned to ID %s was found ', 'wp-graphql-woocommerce' ), $id )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shipping method Model for the shipping method ID.
|
||||
*
|
||||
* @param int $id - Shipping method ID.
|
||||
*
|
||||
* @return Shipping_Method
|
||||
* @access public
|
||||
* @throws UserError Invalid object.
|
||||
*/
|
||||
public static function resolve_shipping_method( $id ) {
|
||||
$wc_shipping = \WC_Shipping::instance();
|
||||
$methods = $wc_shipping->get_shipping_methods();
|
||||
if ( empty( $methods[ $id ] ) ) {
|
||||
throw new UserError(
|
||||
/* translators: shipping method not found error message */
|
||||
sprintf( __( 'No Shipping Method assigned to ID %s was found ', 'wp-graphql-woocommerce' ), $id )
|
||||
);
|
||||
}
|
||||
|
||||
$method = $methods[ $id ];
|
||||
|
||||
return new Shipping_Method( $method );
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves Coupon connections
|
||||
*
|
||||
@@ -123,6 +213,22 @@ class Factory {
|
||||
return $resolver->get_connection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves Order connections
|
||||
*
|
||||
* @param mixed $source - Data resolver for connection source.
|
||||
* @param array $args - Connection arguments.
|
||||
* @param AppContext $context - AppContext object.
|
||||
* @param ResolveInfo $info - ResolveInfo object.
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public static function resolve_order_item_connection( $source, array $args, AppContext $context, ResolveInfo $info ) {
|
||||
$resolver = new Order_Item_Connection_Resolver();
|
||||
return $resolver->resolve( $source, $args, $context, $info );
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves Product connections
|
||||
*
|
||||
@@ -186,4 +292,36 @@ class Factory {
|
||||
$resolver = new Refund_Connection_Resolver( $source, $args, $context, $info );
|
||||
return $resolver->get_connection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves TaxRate connections
|
||||
*
|
||||
* @param mixed $source - Data resolver for connection source.
|
||||
* @param array $args - Connection arguments.
|
||||
* @param AppContext $context - AppContext object.
|
||||
* @param ResolveInfo $info - ResolveInfo object.
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public static function resolve_tax_rate_connection( $source, array $args, AppContext $context, ResolveInfo $info ) {
|
||||
$resolver = new Tax_Rate_Connection_Resolver( $source, $args, $context, $info );
|
||||
return $resolver->get_connection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves ShippingMethod connections
|
||||
*
|
||||
* @param mixed $source - Data resolver for connection source.
|
||||
* @param array $args - Connection arguments.
|
||||
* @param AppContext $context - AppContext object.
|
||||
* @param ResolveInfo $info - ResolveInfo object.
|
||||
*
|
||||
* @return array
|
||||
* @access public
|
||||
*/
|
||||
public static function resolve_shipping_method_connection( $source, array $args, AppContext $context, ResolveInfo $info ) {
|
||||
$resolver = new Shipping_Method_Connection_Resolver();
|
||||
return $resolver->resolve( $source, $args, $context, $info );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* ConnectionResolver - Order_Item_Connection_Resolver
|
||||
*
|
||||
* Resolves connections to Orders
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Data\Connection
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Data\Connection;
|
||||
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use GraphQLRelay\Relay;
|
||||
use WPGraphQL\AppContext;
|
||||
|
||||
/**
|
||||
* Class Order_Item_Connection_Resolver
|
||||
*/
|
||||
class Order_Item_Connection_Resolver {
|
||||
/**
|
||||
* Creates connection
|
||||
*
|
||||
* @param mixed $source - Connection source Model instance.
|
||||
* @param array $args - Connection arguments.
|
||||
* @param AppContext $context - AppContext object.
|
||||
* @param ResolveInfo $info - ResolveInfo object.
|
||||
*/
|
||||
public function resolve( $source, array $args, AppContext $context, ResolveInfo $info ) {
|
||||
global $wpdb;
|
||||
// @codingStandardsIgnoreLine
|
||||
switch ( $info->fieldName ) {
|
||||
case 'taxLines':
|
||||
$type = 'tax';
|
||||
break;
|
||||
case 'shippingLines':
|
||||
$type = 'shipping';
|
||||
break;
|
||||
case 'feeLines':
|
||||
$type = 'fee';
|
||||
break;
|
||||
case 'couponLines':
|
||||
$type = 'coupon';
|
||||
break;
|
||||
default:
|
||||
$type = 'line_item';
|
||||
break;
|
||||
}
|
||||
$items = $source->get_items( $type );
|
||||
|
||||
$connection = Relay::connectionFromArray( $items, $args );
|
||||
$nodes = array();
|
||||
if ( ! empty( $connection['edges'] ) && is_array( $connection['edges'] ) ) {
|
||||
foreach ( $connection['edges'] as $edge ) {
|
||||
$nodes[] = ! empty( $edge['node'] ) ? $edge['node'] : null;
|
||||
}
|
||||
}
|
||||
$connection['nodes'] = ! empty( $nodes ) ? $nodes : null;
|
||||
return ! empty( $items ) ? $connection : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* ConnectionResolver - Shipping_Method_Connection_Resolver
|
||||
*
|
||||
* Resolves connections to ShippingMethod
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Data\Connection
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Data\Connection;
|
||||
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use GraphQLRelay\Relay;
|
||||
use WPGraphQL\AppContext;
|
||||
|
||||
/**
|
||||
* Class Shipping_Method_Connection_Resolver
|
||||
*/
|
||||
class Shipping_Method_Connection_Resolver {
|
||||
/**
|
||||
* Creates connection
|
||||
*
|
||||
* @param mixed $source - Connection source Model instance.
|
||||
* @param array $args - Connection arguments.
|
||||
* @param AppContext $context - AppContext object.
|
||||
* @param ResolveInfo $info - ResolveInfo object.
|
||||
*/
|
||||
public function resolve( $source, array $args, AppContext $context, ResolveInfo $info ) {
|
||||
$wc_shipping = \WC_Shipping::instance();
|
||||
$methods = $wc_shipping->get_shipping_methods();
|
||||
|
||||
// Get shipping method IDs.
|
||||
$methods = array_map(
|
||||
function( $item ) {
|
||||
return $item->id;
|
||||
},
|
||||
$methods
|
||||
);
|
||||
|
||||
$connection = Relay::connectionFromArray( $methods, $args );
|
||||
$nodes = array();
|
||||
if ( ! empty( $connection['edges'] ) && is_array( $connection['edges'] ) ) {
|
||||
foreach ( $connection['edges'] as $edge ) {
|
||||
$nodes[] = ! empty( $edge['node'] ) ? $edge['node'] : null;
|
||||
}
|
||||
}
|
||||
$connection['nodes'] = ! empty( $nodes ) ? $nodes : null;
|
||||
return ! empty( $methods ) ? $connection : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* ConnectionResolver - Tax_Rate_Connection_Resolver
|
||||
*
|
||||
* Resolves connections to Tax Rates
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Data\Connection
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Data\Connection;
|
||||
|
||||
use WPGraphQL\Data\Connection\AbstractConnectionResolver;
|
||||
use GraphQL\Type\Definition\ResolveInfo;
|
||||
use WPGraphQL\AppContext;
|
||||
|
||||
/**
|
||||
* Class Tax_Rate_Connection_Resolver
|
||||
*/
|
||||
class Tax_Rate_Connection_Resolver extends AbstractConnectionResolver {
|
||||
/**
|
||||
* Confirms the uses has the privileges to query Tax Rates
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function should_execute() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates query arguments array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_query_args() {
|
||||
$query_args = array();
|
||||
|
||||
// Prepare for later use.
|
||||
$last = ! empty( $this->args['last'] ) ? $this->args['last'] : null;
|
||||
$first = ! empty( $this->args['first'] ) ? $this->args['first'] : null;
|
||||
|
||||
/**
|
||||
* Collect the input_fields and sanitize them to prepare them for sending to the WP_Query
|
||||
*/
|
||||
$input_fields = [];
|
||||
if ( ! empty( $this->args['where'] ) ) {
|
||||
$input_fields = $this->sanitize_input_fields( $this->args['where'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $input_fields ) ) {
|
||||
$query_args = array_merge( $query_args, $input_fields );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set posts_per_page the highest value of $first and $last, with a (filterable) max of 100
|
||||
*/
|
||||
$query_args['items_per_page'] = min( max( absint( $first ), absint( $last ), 10 ), $this->query_amount ) + 1;
|
||||
|
||||
/**
|
||||
* Set the graphql_cursor_offset which is used by Config::graphql_wp_query_cursor_pagination_support
|
||||
* to filter the WP_Query to support cursor pagination
|
||||
*/
|
||||
$cursor_offset = $this->get_offset();
|
||||
$query_args['graphql_cursor_offset'] = $cursor_offset;
|
||||
$query_args['graphql_cursor_compare'] = ( ! empty( $last ) ) ? '>' : '<';
|
||||
|
||||
/**
|
||||
* If there's no orderby params in the inputArgs, set order based on the first/last argument
|
||||
*/
|
||||
if ( empty( $query_args['orderby'] ) ) {
|
||||
$query_args['orderby'] = 'tax_rate_order';
|
||||
$query_args['order'] = ! empty( $last ) ? 'ASC' : 'DESC';
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the $query args to allow folks to customize queries programmatically
|
||||
*
|
||||
* @param array $query_args The args that will be passed to the WP_Query
|
||||
* @param mixed $source The source that's passed down the GraphQL queries
|
||||
* @param array $args The inputArgs on the field
|
||||
* @param AppContext $context The AppContext passed down the GraphQL tree
|
||||
* @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree
|
||||
*/
|
||||
$query_args = apply_filters( 'graphql_tax_rate_connection_query_args', $query_args, $this->source, $this->args, $this->context, $this->info );
|
||||
|
||||
return $query_args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_query() {
|
||||
global $wpdb;
|
||||
|
||||
$results = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT tax_rate_id
|
||||
FROM {$wpdb->prefix}woocommerce_tax_rates
|
||||
WHERE 1 = 1
|
||||
ORDER BY %s",
|
||||
$this->query_args['orderby']
|
||||
)
|
||||
);
|
||||
|
||||
$results = array_map(
|
||||
function( $rate ) {
|
||||
return $rate->tax_rate_id;
|
||||
},
|
||||
(array) $results
|
||||
);
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of items from the query
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_items() {
|
||||
return ! empty( $this->query ) ? $this->query : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* This sets up the "allowed" args, and translates the GraphQL-friendly keys to WP_Query
|
||||
* friendly keys. There's probably a cleaner/more dynamic way to approach this, but
|
||||
* this was quick. I'd be down to explore more dynamic ways to map this, but for
|
||||
* now this gets the job done.
|
||||
*
|
||||
* @param array $where_args - arguments being used to filter query.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sanitize_input_fields( array $where_args ) {
|
||||
$args = array();
|
||||
if ( ! empty( $where_args['orderby'] ) ) {
|
||||
$orderby_possibles = array(
|
||||
'id' => 'tax_rate_id',
|
||||
'order' => 'tax_rate_order',
|
||||
);
|
||||
$args['orderby'] = $orderby_possibles[ $where_args['orderby'] ];
|
||||
}
|
||||
|
||||
$args['class'] = $where_args['class'];
|
||||
return $args;
|
||||
}
|
||||
}
|
||||
@@ -58,9 +58,11 @@ abstract class Crud_CPT extends Model {
|
||||
*
|
||||
* @param string $method - function name.
|
||||
* @param array $args - function call arguments.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call( $method, $args ) {
|
||||
$this->data->$method( ...$args );
|
||||
return $this->data->$method( ...$args );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
<?php
|
||||
/**
|
||||
* Model - Order_Item
|
||||
*
|
||||
* Resolves model for order item crud objects
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Model
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Model;
|
||||
|
||||
use GraphQLRelay\Relay;
|
||||
use WPGraphQL\Model\Model;
|
||||
|
||||
/**
|
||||
* Class Order_Item
|
||||
*/
|
||||
class Order_Item extends Model {
|
||||
|
||||
/**
|
||||
* Stores order item type
|
||||
*
|
||||
* @var int $item_type
|
||||
* @access protected
|
||||
*/
|
||||
protected $item_type;
|
||||
|
||||
/**
|
||||
* Order_Item constructor
|
||||
*
|
||||
* @param int $item - order item crud object.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $item ) {
|
||||
$this->data = $item;
|
||||
$this->item_type = $item->get_type();
|
||||
$allowed_restricted_fields = array(
|
||||
'isRestricted',
|
||||
'isPrivate',
|
||||
'isPublic',
|
||||
'id',
|
||||
'orderItemId',
|
||||
);
|
||||
|
||||
parent::__construct( '', $allowed_restricted_fields, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the order item should be considered private
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_private() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Order field resolvers
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function init() {
|
||||
if ( empty( $this->fields ) ) {
|
||||
$this->fields = array(
|
||||
'ID' => function() {
|
||||
return $this->data->get_id();
|
||||
},
|
||||
'itemId' => function() {
|
||||
return ! empty( $this->data->get_id() ) ? $this->data->get_id() : null;
|
||||
},
|
||||
'orderId' => function() {
|
||||
return ! empty( $this->data->get_order_id() ) ? $this->data->get_order_id() : null;
|
||||
},
|
||||
'type' => function() {
|
||||
return ! empty( $this->data->get_type() ) ? $this->data->get_type() : null;
|
||||
},
|
||||
);
|
||||
|
||||
switch ( $this->item_type ) {
|
||||
case 'coupon':
|
||||
$this->fields = array_merge(
|
||||
$this->fields,
|
||||
array(
|
||||
'code' => function() {
|
||||
return ! empty( $this->data->get_code() ) ? $this->data->get_code() : null;
|
||||
},
|
||||
'discount' => function() {
|
||||
return ! empty( $this->data->get_discount() ) ? $this->data->get_discount() : null;
|
||||
},
|
||||
'discountTax' => function() {
|
||||
return ! empty( $this->data->get_discount_tax() ) ? $this->data->get_discount_tax() : null;
|
||||
},
|
||||
'coupon_id' => array(
|
||||
'callback' => function() {
|
||||
$coupon_id = \wc_get_coupon_id_by_code( $this->data->get_code() );
|
||||
return ! empty( $coupon_id ) ? $coupon_id : null;
|
||||
},
|
||||
'capability' => 'edit_shop_orders',
|
||||
),
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fee':
|
||||
$this->fields = array_merge(
|
||||
$this->fields,
|
||||
array(
|
||||
'amount' => function() {
|
||||
return ! empty( $this->data->get_amount() ) ? $this->data->get_amount() : null;
|
||||
},
|
||||
'name' => function() {
|
||||
return ! empty( $this->data->get_name() ) ? $this->data->get_name() : null;
|
||||
},
|
||||
'taxStatus' => function() {
|
||||
return ! empty( $this->data->get_tax_status() ) ? $this->data->get_tax_status() : null;
|
||||
},
|
||||
'taxClass' => function() {
|
||||
if ( $this->data->get_tax_status() === 'taxable' ) {
|
||||
return ! empty( $this->data->get_tax_class() )
|
||||
? $this->data->get_tax_class()
|
||||
: 'standard';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
'total' => function() {
|
||||
return ! empty( $this->data->get_total() ) ? $this->data->get_total() : null;
|
||||
},
|
||||
'totalTax' => function() {
|
||||
return ! empty( $this->data->get_total_tax() ) ? $this->data->get_total_tax() : null;
|
||||
},
|
||||
'taxes' => function() {
|
||||
return ! empty( $this->data->get_taxes() )
|
||||
? \wc_graphql_map_tax_statements( $this->data->get_taxes() )
|
||||
: null;
|
||||
},
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'shipping':
|
||||
$this->fields = array_merge(
|
||||
$this->fields,
|
||||
array(
|
||||
'name' => function() {
|
||||
return ! empty( $this->data->get_name() ) ? $this->data->get_name() : null;
|
||||
},
|
||||
'methodTitle' => function() {
|
||||
return ! empty( $this->data->get_method_title() ) ? $this->data->get_method_title() : null;
|
||||
},
|
||||
'total' => function() {
|
||||
return ! empty( $this->data->get_total() ) ? $this->data->get_total() : null;
|
||||
},
|
||||
'totalTax' => function() {
|
||||
return ! empty( $this->data->get_total_tax() ) ? $this->data->get_total_tax() : null;
|
||||
},
|
||||
'taxes' => function() {
|
||||
return ! empty( $this->data->get_taxes() )
|
||||
? \wc_graphql_map_tax_statements( $this->data->get_taxes() )
|
||||
: null;
|
||||
},
|
||||
'taxClass' => function() {
|
||||
return is_callable( $this->data, 'get_tax_class' ) ? $this->data->get_tax_class() : 'standard';
|
||||
},
|
||||
'method_id' => function() {
|
||||
return ! empty( $this->data->get_method_id() ) ? $this->data->get_method_id() : null;
|
||||
},
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'tax':
|
||||
$this->fields = array_merge(
|
||||
$this->fields,
|
||||
array(
|
||||
'rateCode' => function() {
|
||||
return ! empty( $this->data->get_rate_code() ) ? $this->data->get_rate_code() : null;
|
||||
},
|
||||
'label' => function() {
|
||||
return ! empty( $this->data->get_label() ) ? $this->data->get_label() : null;
|
||||
},
|
||||
'taxTotal' => function() {
|
||||
return ! empty( $this->data->get_tax_total() ) ? $this->data->get_tax_total() : null;
|
||||
},
|
||||
'shippingTaxTotal' => function() {
|
||||
return ! empty( $this->data->get_shipping_tax_total() ) ? $this->data->get_shipping_tax_total() : null;
|
||||
},
|
||||
'isCompound' => function() {
|
||||
return ! empty( $this->data->is_compound() ) ? $this->data->is_compound() : null;
|
||||
},
|
||||
'rate_id' => function() {
|
||||
return ! empty( $this->data->get_rate_id() ) ? $this->data->get_rate_id() : null;
|
||||
},
|
||||
)
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$this->fields = array_merge(
|
||||
$this->fields,
|
||||
array(
|
||||
'productId' => function() {
|
||||
return ! empty( $this->data->get_product_id() ) ? $this->data->get_product_id() : null;
|
||||
},
|
||||
'variationId' => function() {
|
||||
return ! empty( $this->data->get_variation_id() ) ? $this->data->get_variation_id() : null;
|
||||
},
|
||||
'quantity' => function() {
|
||||
return ! empty( $this->data->get_quantity() ) ? $this->data->get_quantity() : null;
|
||||
},
|
||||
'subtotal' => function() {
|
||||
return ! empty( $this->data->get_subtotal() ) ? $this->data->get_subtotal() : null;
|
||||
},
|
||||
'subtotalTax' => function() {
|
||||
return ! empty( $this->data->get_subtotal_tax() ) ? $this->data->get_subtotal_tax() : null;
|
||||
},
|
||||
'total' => function() {
|
||||
return ! empty( $this->data->get_total() ) ? $this->data->get_total() : null;
|
||||
},
|
||||
'totalTax' => function() {
|
||||
return ! empty( $this->data->get_total_tax() ) ? $this->data->get_total_tax() : null;
|
||||
},
|
||||
'taxes' => function() {
|
||||
return ! empty( $this->data->get_taxes() )
|
||||
? \wc_graphql_map_tax_statements( $this->data->get_taxes() )
|
||||
: null;
|
||||
},
|
||||
'itemDownloads' => function() {
|
||||
return ! empty( $this->data->get_item_downloads() ) ? $this->data->get_item_downloads() : null;
|
||||
},
|
||||
'taxStatus' => function() {
|
||||
return ! empty( $this->data->get_tax_status() ) ? $this->data->get_tax_status() : null;
|
||||
},
|
||||
'taxClass' => function() {
|
||||
if ( $this->data->get_tax_status() === 'taxable' ) {
|
||||
return ! empty( $this->data->get_tax_class() )
|
||||
? $this->data->get_tax_class()
|
||||
: 'standard';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
parent::prepare_fields();
|
||||
}
|
||||
}
|
||||
@@ -11,13 +11,16 @@
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Model;
|
||||
|
||||
use GraphQLRelay\Relay;
|
||||
use WPGraphQL\Data\DataSource;
|
||||
use WPGraphQL\Model\Model;
|
||||
|
||||
/**
|
||||
* Class Order
|
||||
*/
|
||||
class Order extends Crud_CPT {
|
||||
/**
|
||||
* Defines get_restricted_cap
|
||||
*/
|
||||
use Shop_Manager_Caps;
|
||||
|
||||
/**
|
||||
* Order constructor
|
||||
*
|
||||
@@ -39,30 +42,6 @@ class Order extends Crud_CPT {
|
||||
parent::__construct( $allowed_restricted_fields, 'shop_order', $id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the cap to check if the data should be restricted for the order
|
||||
*
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function get_restricted_cap() {
|
||||
if ( post_password_required( $this->data->get_id() ) ) {
|
||||
return $this->post_type_object->cap->edit_others_posts;
|
||||
}
|
||||
switch ( get_post_status( $this->data->get_id() ) ) {
|
||||
case 'trash':
|
||||
$cap = $this->post_type_object->cap->edit_posts;
|
||||
break;
|
||||
case 'draft':
|
||||
$cap = $this->post_type_object->cap->edit_others_posts;
|
||||
break;
|
||||
default:
|
||||
$cap = '';
|
||||
break;
|
||||
}
|
||||
return $cap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Order field resolvers
|
||||
*
|
||||
|
||||
@@ -17,7 +17,12 @@ use WPGraphQL\Model\Model;
|
||||
/**
|
||||
* Class Refund
|
||||
*/
|
||||
class Refund extends Model {
|
||||
class Refund extends Crud_CPT {
|
||||
/**
|
||||
* Defines get_restricted_cap
|
||||
*/
|
||||
use Shop_Manager_Caps;
|
||||
|
||||
/**
|
||||
* Refund constructor
|
||||
*
|
||||
@@ -36,7 +41,7 @@ class Refund extends Model {
|
||||
'refundId',
|
||||
];
|
||||
|
||||
parent::__construct( 'list_users', $allowed_restricted_fields, $id );
|
||||
parent::__construct( $allowed_restricted_fields, 'shop_order_refund', $id );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +56,7 @@ class Refund extends Model {
|
||||
return $this->data->get_id();
|
||||
},
|
||||
'id' => function() {
|
||||
return ! empty( $this->data ) ? Relay::toGlobalId( 'shop_order', $this->data->get_id() ) : null;
|
||||
return ! empty( $this->data ) ? Relay::toGlobalId( 'shop_order_refund', $this->data->get_id() ) : null;
|
||||
},
|
||||
'refundId' => function() {
|
||||
return ! empty( $this->data ) ? $this->data->get_id() : null;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Model - Shipping_Method
|
||||
*
|
||||
* Resolves shipping method object model
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Model
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Model;
|
||||
|
||||
use GraphQLRelay\Relay;
|
||||
use WPGraphQL\Model\Model;
|
||||
|
||||
/**
|
||||
* Class Shipping_Method
|
||||
*/
|
||||
class Shipping_Method extends Model {
|
||||
/**
|
||||
* Shipping_Method constructor
|
||||
*
|
||||
* @param int $method - Shipping method object.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $method ) {
|
||||
$this->data = $method;
|
||||
$allowed_restricted_fields = array(
|
||||
'isRestricted',
|
||||
'isPrivate',
|
||||
'isPublic',
|
||||
'id',
|
||||
'rateId',
|
||||
);
|
||||
|
||||
parent::__construct( '', $allowed_restricted_fields, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the order item should be considered private
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_private() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Order field resolvers
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function init() {
|
||||
if ( empty( $this->fields ) ) {
|
||||
$this->fields = array(
|
||||
'ID' => function() {
|
||||
return $this->data->id;
|
||||
},
|
||||
'id' => function() {
|
||||
return ! empty( $this->data->id ) ? Relay::toGlobalId( 'shipping_method', $this->data->id ) : null;
|
||||
},
|
||||
'methodId' => function() {
|
||||
return ! empty( $this->data->id ) ? $this->data->id : null;
|
||||
},
|
||||
'title' => function() {
|
||||
return ! empty( $this->data->method_title ) ? $this->data->method_title : null;
|
||||
},
|
||||
'description' => function() {
|
||||
return ! empty( $this->data->method_description ) ? $this->data->method_description : null;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Model - Tax_Rate
|
||||
*
|
||||
* Resolves tax rate object model
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Model
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Model;
|
||||
|
||||
use GraphQLRelay\Relay;
|
||||
use WPGraphQL\Model\Model;
|
||||
|
||||
/**
|
||||
* Class Tax_Rate
|
||||
*/
|
||||
class Tax_Rate extends Model {
|
||||
/**
|
||||
* Tax_Rate constructor
|
||||
*
|
||||
* @param int $rate - Tax rate object.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $rate ) {
|
||||
$this->data = $rate;
|
||||
$allowed_restricted_fields = array(
|
||||
'isRestricted',
|
||||
'isPrivate',
|
||||
'isPublic',
|
||||
'id',
|
||||
'rateId',
|
||||
);
|
||||
|
||||
parent::__construct( '', $allowed_restricted_fields, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the order item should be considered private
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_private() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Order field resolvers
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
protected function init() {
|
||||
if ( empty( $this->fields ) ) {
|
||||
$this->fields = array(
|
||||
'ID' => function() {
|
||||
return $this->data->tax_rate_id;
|
||||
},
|
||||
'id' => function() {
|
||||
return ! empty( $this->data->tax_rate_id ) ? Relay::toGlobalId( 'tax_rate', $this->data->tax_rate_id ) : null;
|
||||
},
|
||||
'rateId' => function() {
|
||||
return ! empty( $this->data->tax_rate_id ) ? $this->data->tax_rate_id : null;
|
||||
},
|
||||
'country' => function() {
|
||||
return ! empty( $this->data->tax_rate_country ) ? $this->data->tax_rate_country : null;
|
||||
},
|
||||
'state' => function() {
|
||||
return ! empty( $this->data->tax_rate_state ) ? $this->data->tax_rate_state : null;
|
||||
},
|
||||
'city' => function() {
|
||||
return ! empty( $this->data->tax_rate_city ) ? $this->data->tax_rate_city : array( '*' );
|
||||
},
|
||||
'postcode' => function() {
|
||||
return ! empty( $this->data->tax_rate_postcode ) ? $this->data->tax_rate_postcode : array( '*' );
|
||||
},
|
||||
'rate' => function() {
|
||||
return ! empty( $this->data->tax_rate ) ? $this->data->tax_rate : null;
|
||||
},
|
||||
'name' => function() {
|
||||
return ! empty( $this->data->tax_rate_name ) ? $this->data->tax_rate_name : null;
|
||||
},
|
||||
'priority' => function() {
|
||||
return ! empty( $this->data->tax_rate_priority ) ? $this->data->tax_rate_priority : null;
|
||||
},
|
||||
'compound' => function() {
|
||||
return ! empty( $this->data->tax_rate_compound ) ? $this->data->tax_rate_compound : null;
|
||||
},
|
||||
'shipping' => function() {
|
||||
return ! empty( $this->data->tax_rate_shipping ) ? $this->data->tax_rate_shipping : null;
|
||||
},
|
||||
'order' => function() {
|
||||
return ! empty( $this->data->tax_rate_order ) ? $this->data->tax_rate_order : null;
|
||||
},
|
||||
'class' => function() {
|
||||
return ! empty( $this->data->tax_rate_class ) ? $this->data->tax_rate_class : 'standard';
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Defines Admin only restriction caps.
|
||||
*
|
||||
* @package WPGraphQL\Extensions\WooCommerce\Model
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Model;
|
||||
|
||||
use GraphQLRelay\Relay;
|
||||
/**
|
||||
* Trait Shop_Manager_Capabilities
|
||||
*/
|
||||
trait Shop_Manager_Caps {
|
||||
/**
|
||||
* Retrieve the cap to check if the data should be restricted for the order
|
||||
*
|
||||
* @access protected
|
||||
* @return string
|
||||
*/
|
||||
protected function get_restricted_cap() {
|
||||
if ( post_password_required( $this->data->get_id() ) ) {
|
||||
return $this->post_type_object->cap->edit_others_posts;
|
||||
}
|
||||
switch ( get_post_status( $this->data->get_id() ) ) {
|
||||
case 'draft':
|
||||
$cap = $this->post_type_object->cap->edit_others_posts;
|
||||
break;
|
||||
default:
|
||||
$cap = $this->post_type_object->cap->edit_posts;
|
||||
break;
|
||||
}
|
||||
return $cap;
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,11 @@ class Stock_Status {
|
||||
* Registers type
|
||||
*/
|
||||
public static function register() {
|
||||
$values = [
|
||||
$values = array(
|
||||
'IN_STOCK' => array( 'value' => 'instock' ),
|
||||
'OUT_OF_STOCK' => array( 'value' => 'outofstock' ),
|
||||
'ON_BACKORDER' => array( 'value' => 'onbackorder' ),
|
||||
];
|
||||
);
|
||||
|
||||
register_graphql_enum_type(
|
||||
'StockStatusEnum',
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* WPEnum Type - TaxClassEnum
|
||||
*
|
||||
* @package \WPGraphQL\Extensions\WooCommerce\Type\WPEnum
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Type\WPEnum;
|
||||
|
||||
use WPGraphQL\Type\WPEnumType;
|
||||
|
||||
/**
|
||||
* Class Tax_Class
|
||||
*/
|
||||
class Tax_Class {
|
||||
/**
|
||||
* Registers type
|
||||
*/
|
||||
public static function register() {
|
||||
$values = array(
|
||||
WPEnumType::get_safe_name( 'inherit cart' ) => array(
|
||||
'value' => 'inherit',
|
||||
'description' => __( 'Inherits Tax class from cart', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
WPEnumType::get_safe_name( 'standard' ) => array(
|
||||
'value' => 'standard',
|
||||
'description' => __( 'Standard Tax rate', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
);
|
||||
|
||||
$classes = \WC_Tax::get_tax_classes();
|
||||
foreach ( $classes as $class ) {
|
||||
$values[ WPEnumType::get_safe_name( $class ) ] = array( 'value' => sanitize_title( $class ) );
|
||||
}
|
||||
|
||||
register_graphql_enum_type(
|
||||
'TaxClassEnum',
|
||||
array(
|
||||
'description' => __( 'Tax class enumeration', 'wp-graphql' ),
|
||||
'values' => $values,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* WPEnum Type - TaxRateConnectionOrderbyInput
|
||||
*
|
||||
* @package \WPGraphQL\Extensions\WooCommerce\Type\WPEnum
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Type\WPEnum;
|
||||
|
||||
/**
|
||||
* Class Tax_Rate_Connection_Orderby_Enum
|
||||
*/
|
||||
class Tax_Rate_Connection_Orderby_Enum {
|
||||
/**
|
||||
* Registers type
|
||||
*/
|
||||
public static function register() {
|
||||
register_graphql_enum_type(
|
||||
'TaxRateConnectionOrderbyEnum',
|
||||
array(
|
||||
'description' => __( 'Field to order the connection by', 'wp-graphql-woocommerce' ),
|
||||
'values' => array(
|
||||
'ID' => array( 'value' => 'id' ),
|
||||
'ORDER' => array( 'value' => 'order' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* WPInputObjectType - TaxRateConnectionOrderbyInput
|
||||
*
|
||||
* @package \WPGraphQL\Extensions\WooCommerce\Type\WPInputObject
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Type\WPInputObject;
|
||||
|
||||
/**
|
||||
* Class Tax_Rate_Connection_Orderby_Input
|
||||
*/
|
||||
class Tax_Rate_Connection_Orderby_Input {
|
||||
/**
|
||||
* Registers type
|
||||
*/
|
||||
public static function register() {
|
||||
register_graphql_input_type(
|
||||
'TaxRateConnectionOrderbyInput',
|
||||
array(
|
||||
'description' => __( 'Options for ordering the connection', 'wp-graphql-woocommerce' ),
|
||||
'fields' => array(
|
||||
'field' => array(
|
||||
'type' => array( 'non_null' => 'TaxRateConnectionOrderbyEnum' ),
|
||||
),
|
||||
'order' => array(
|
||||
'type' => 'OrderEnum',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class Coupon_Type {
|
||||
* Register Coupon type and queries to the WPGraphQL schema
|
||||
*/
|
||||
public static function register() {
|
||||
register_graphql_object_type(
|
||||
wc_register_graphql_object_type(
|
||||
'Coupon',
|
||||
array(
|
||||
'description' => __( 'A coupon object', 'wp-graphql-woocommerce' ),
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
<?php
|
||||
/**
|
||||
* WPObject Type - Order_Item_Type
|
||||
*
|
||||
* Registers OrderItem WPObject type and queries
|
||||
*
|
||||
* @package \WPGraphQL\Extensions\WooCommerce\Type\WPObject
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Type\WPObject;
|
||||
|
||||
use WPGraphQL\AppContext;
|
||||
use WPGraphQL\Extensions\WooCommerce\Data\Factory;
|
||||
|
||||
/**
|
||||
* Class Order_Item_Type
|
||||
*/
|
||||
class Order_Item_Type {
|
||||
/**
|
||||
* Register order item type
|
||||
*/
|
||||
public static function register() {
|
||||
$types = array(
|
||||
'CouponLine' => array(
|
||||
// Description.
|
||||
__( 'a coupon line object', 'wp-graphql-woocommerce' ),
|
||||
// Fields.
|
||||
array(
|
||||
'code' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line\'s Coupon code', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'discount' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line\'s Discount total', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'discountTax' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line\'s Discount total tax', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'coupon' => array(
|
||||
'type' => 'Coupon',
|
||||
'description' => __( 'Line\'s Coupon', 'wp-graphql-woocommerce' ),
|
||||
'resolve' => function( $source, array $args, AppContext $context ) {
|
||||
return Factory::resolve_crud_object( $source->coupon_id, $context );
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
'FeeLine' => array(
|
||||
// Description.
|
||||
__( 'a fee line object', 'wp-graphql-woocommerce' ),
|
||||
// Fields.
|
||||
array(
|
||||
'amount' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Fee amount', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Fee name', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxStatus' => array(
|
||||
'type' => 'TaxStatusEnum',
|
||||
'description' => __( 'Tax status of fee', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'total' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line total (after discounts)', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'totalTax' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line total tax (after discounts)', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxes' => array(
|
||||
'type' => array( 'list_of' => 'OrderItemTax' ),
|
||||
'description' => __( 'Line taxes', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxClass' => array(
|
||||
'type' => 'TaxClassEnum',
|
||||
'description' => __( 'Line tax class', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
'ShippingLine' => array(
|
||||
// Description.
|
||||
__( 'a shipping line object', 'wp-graphql-woocommerce' ),
|
||||
// Fields.
|
||||
array(
|
||||
'methodTitle' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Shipping Line\'s shipping method name', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'total' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line total (after discounts)', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'totalTax' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line total tax (after discounts)', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxes' => array(
|
||||
'type' => array( 'list_of' => 'OrderItemTax' ),
|
||||
'description' => __( 'Line taxes', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxClass' => array(
|
||||
'type' => 'TaxClassEnum',
|
||||
'description' => __( 'Line tax class', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'shippingMethod' => array(
|
||||
'type' => 'ShippingMethod',
|
||||
'description' => __( 'Shipping Line\'s shipping method', 'wp-graphql-woocommerce' ),
|
||||
'resolve' => function( $source ) {
|
||||
return Factory::resolve_shipping_method( $source->method_id );
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
'TaxLine' => array(
|
||||
// Description.
|
||||
__( 'a tax line object', 'wp-graphql-woocommerce' ),
|
||||
// Fields.
|
||||
array(
|
||||
'rateCode' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Tax rate code/name', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'label' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Tax rate label', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxTotal' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Tax total (not including shipping taxes)', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'shippingTaxTotal' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Tax line\'s shipping tax total', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'isCompound' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'Is this a compound tax rate?', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxRate' => array(
|
||||
'type' => 'TaxRate',
|
||||
'description' => __( 'Tax line\'s tax rate', 'wp-graphql-woocommerce' ),
|
||||
'resolve' => function( $source ) {
|
||||
return Factory::resolve_tax_rate( $source->rate_id );
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
'LineItem' => array(
|
||||
// Description.
|
||||
__( 'a line item object', 'wp-graphql-woocommerce' ),
|
||||
// Fields.
|
||||
array(
|
||||
'productId' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'Line item\'s product ID', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'variationId' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'Line item\'s product variation ID', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'quantity' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'Line item\'s product quantity', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxClass' => array(
|
||||
'type' => 'TaxClassEnum',
|
||||
'description' => __( 'Line item\'s tax class', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'subtotal' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line item\'s subtotal', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'subtotalTax' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line item\'s subtotal tax', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'total' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line item\'s total', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'totalTax' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Line item\'s total tax', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxes' => array(
|
||||
'type' => array( 'list_of' => 'OrderItemTax' ),
|
||||
'description' => __( 'Line item\'s taxes', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'itemDownloads' => array(
|
||||
'type' => array( 'list_of' => 'ProductDownload' ),
|
||||
'description' => __( 'Line item\'s taxes', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxStatus' => array(
|
||||
'type' => 'TaxStatusEnum',
|
||||
'description' => __( 'Line item\'s taxes', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Registers order item objects.
|
||||
foreach ( $types as $type_name => $config ) {
|
||||
register_graphql_object_type(
|
||||
$type_name,
|
||||
array(
|
||||
'description' => $config[0],
|
||||
'fields' => self::get_fields( $config[1] ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Registers tax statement object.
|
||||
register_graphql_object_type(
|
||||
'OrderItemTax',
|
||||
array(
|
||||
'description' => __( 'Order item tax statement', 'wp-graphql-woocommercer' ),
|
||||
'fields' => array(
|
||||
'taxLineId' => array(
|
||||
'type' => array( 'non_null' => 'Int' ),
|
||||
'description' => __( 'Order item ID for tax line connected to this statement', 'wp-graphql-woocommerce' ),
|
||||
'resolve' => function( $source ) {
|
||||
return ! empty( $source['ID'] ) ? $source['ID'] : null;
|
||||
},
|
||||
),
|
||||
'subtotal' => array(
|
||||
'type' => 'Float',
|
||||
'description' => __( 'Subtotal', 'wp-graphql-woocommerce' ),
|
||||
'resolve' => function( $source ) {
|
||||
return ! empty( $source['subtotal'] ) ? $source['subtotal'] : null;
|
||||
},
|
||||
),
|
||||
'total' => array(
|
||||
'type' => 'Float',
|
||||
'description' => __( 'Total', 'wp-graphql-woocommerce' ),
|
||||
'resolve' => function( $source ) {
|
||||
return ! empty( $source['total'] ) ? $source['total'] : null;
|
||||
},
|
||||
),
|
||||
'amount' => array(
|
||||
'type' => 'Float',
|
||||
'description' => __( 'Amount taxed', 'wp-graphql-woocommerce' ),
|
||||
'resolve' => function( $source ) {
|
||||
return ! empty( $source['amount'] ) ? $source['amount'] : null;
|
||||
},
|
||||
),
|
||||
'taxLine' => array(
|
||||
'type' => 'TaxLine',
|
||||
'description' => __( 'Tax line connected to this statement', 'wp-graphql-woocommerce' ),
|
||||
'resolve' => function( $source ) {
|
||||
$item = new \WC_Order_Item_Tax( $source['ID'] );
|
||||
return ! empty( $item ) ? Factory::resolve_order_item( $item ) : null;
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns type fields definition
|
||||
*
|
||||
* @param array $fields - type specific fields.
|
||||
* @return array
|
||||
*/
|
||||
private static function get_fields( $fields = array() ) {
|
||||
return array_merge(
|
||||
array(
|
||||
'itemId' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'The Id of the order item.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'orderId' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'The Id of the order the order item belongs to.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
),
|
||||
$fields
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class Order_Type {
|
||||
* Register Order type and queries to the WPGraphQL schema
|
||||
*/
|
||||
public static function register() {
|
||||
register_graphql_object_type(
|
||||
wc_register_graphql_object_type(
|
||||
'Order',
|
||||
array(
|
||||
'description' => __( 'A order object', 'wp-graphql-woocommerce' ),
|
||||
|
||||
@@ -26,7 +26,7 @@ class Product_Type {
|
||||
* Register Product type and queries to the WPGraphQL schema
|
||||
*/
|
||||
public static function register() {
|
||||
register_graphql_object_type(
|
||||
wc_register_graphql_object_type(
|
||||
'Product',
|
||||
array(
|
||||
'description' => __( 'A product object', 'wp-graphql-woocommerce' ),
|
||||
@@ -155,7 +155,7 @@ class Product_Type {
|
||||
'description' => __( 'Tax status', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxClass' => array(
|
||||
'type' => 'String',
|
||||
'type' => 'TaxClassEnum',
|
||||
'description' => __( 'Tax class', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'manageStock' => array(
|
||||
|
||||
@@ -26,7 +26,7 @@ class Product_Variation_Type {
|
||||
* Register ProductVariation type to the WPGraphQL schema
|
||||
*/
|
||||
public static function register() {
|
||||
register_graphql_object_type(
|
||||
wc_register_graphql_object_type(
|
||||
'ProductVariation',
|
||||
array(
|
||||
'description' => __( 'A product variation object', 'wp-graphql-woocommerce' ),
|
||||
@@ -61,7 +61,7 @@ class Product_Variation_Type {
|
||||
'description' => __( 'Product variation height', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'taxClass' => array(
|
||||
'type' => 'String',
|
||||
'type' => 'TaxClassEnum',
|
||||
'description' => __( 'Product variation tax class', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'manageStock' => array(
|
||||
@@ -138,7 +138,7 @@ class Product_Variation_Type {
|
||||
'description' => __( 'A product variation object', 'wp-graphql-woocommerce' ),
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'type' => array( 'non_null' => 'ID' ),
|
||||
'type' => 'ID',
|
||||
'description' => __( 'Get the product variation by its global ID', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'variationId' => array(
|
||||
|
||||
@@ -27,7 +27,7 @@ class Refund_Type {
|
||||
* Register Refund type and queries to the WPGraphQL schema
|
||||
*/
|
||||
public static function register() {
|
||||
register_graphql_object_type(
|
||||
wc_register_graphql_object_type(
|
||||
'Refund',
|
||||
array(
|
||||
'description' => __( 'A refund object', 'wp-graphql-woocommerce' ),
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* WPObject Type - Shipping_Method_Type
|
||||
*
|
||||
* Registers ShippingMethod WPObject type and queries
|
||||
*
|
||||
* @package \WPGraphQL\Extensions\WooCommerce\Type\WPObject
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Type\WPObject;
|
||||
|
||||
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;
|
||||
use WPGraphQL\Extensions\WooCommerce\Model\Shipping_Method;
|
||||
|
||||
/**
|
||||
* Class Shipping_Method_Type
|
||||
*/
|
||||
class Shipping_Method_Type {
|
||||
/**
|
||||
* Registers shipping method type
|
||||
*/
|
||||
public static function register() {
|
||||
wc_register_graphql_object_type(
|
||||
'ShippingMethod',
|
||||
array(
|
||||
'description' => __( 'A shipping method object', 'wp-graphql-woocommercer' ),
|
||||
'interfaces' => [ WPObjectType::node_interface() ],
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'type' => array( 'non_null' => 'ID' ),
|
||||
'description' => __( 'The globally unique identifier for the tax rate.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'methodId' => array(
|
||||
'type' => array( 'non_null' => 'ID' ),
|
||||
'description' => __( 'The ID of the tax rate.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Shipping method title.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'description' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Shipping method description.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
),
|
||||
'resolve_node' => function( $node, $id, $type, AppContext $context ) {
|
||||
if ( 'tax_rate' === $type ) {
|
||||
$node = Factory::resolve_shipping_method( $id );
|
||||
}
|
||||
|
||||
return $node;
|
||||
},
|
||||
'resolve_node_type' => function( $type, $node ) {
|
||||
if ( is_a( $node, Shipping_Method::class ) ) {
|
||||
$type = 'ShippingMethod';
|
||||
}
|
||||
|
||||
return $type;
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
register_graphql_field(
|
||||
'RootQuery',
|
||||
'shippingMethod',
|
||||
array(
|
||||
'type' => 'ShippingMethod',
|
||||
'description' => __( 'A shipping method object', 'wp-graphql-woocommerce' ),
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'type' => 'ID',
|
||||
'description' => __( 'Get the shipping method by its global ID', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'methodId' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'Get the shipping method by its database ID', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
),
|
||||
'resolve' => function ( $source, array $args ) {
|
||||
$method_id = 0;
|
||||
if ( ! empty( $args['id'] ) ) {
|
||||
$id_components = Relay::fromGlobalId( $args['id'] );
|
||||
if ( empty( $id_components['id'] ) || empty( $id_components['type'] ) ) {
|
||||
throw new UserError( __( 'The "id" is invalid', 'wp-graphql-woocommerce' ) );
|
||||
}
|
||||
|
||||
$arg = 'ID';
|
||||
$method_id = absint( $id_components['id'] );
|
||||
} elseif ( ! empty( $args['methodId'] ) ) {
|
||||
$arg = 'database ID';
|
||||
$method_id = absint( $args['methodId'] );
|
||||
}
|
||||
|
||||
return Factory::resolve_shipping_method( $method_id );
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* WPObject Type - Tax_Rate_Type
|
||||
*
|
||||
* Registers TaxRate WPObject type and queries
|
||||
*
|
||||
* @package \WPGraphQL\Extensions\WooCommerce\Type\WPObject
|
||||
* @since 0.0.2
|
||||
*/
|
||||
|
||||
namespace WPGraphQL\Extensions\WooCommerce\Type\WPObject;
|
||||
|
||||
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;
|
||||
use WPGraphQL\Extensions\WooCommerce\Model\Tax_Rate;
|
||||
|
||||
/**
|
||||
* Class Tax_Rate_Type
|
||||
*/
|
||||
class Tax_Rate_Type {
|
||||
/**
|
||||
* Registers tax rate type
|
||||
*/
|
||||
public static function register() {
|
||||
wc_register_graphql_object_type(
|
||||
'TaxRate',
|
||||
array(
|
||||
'description' => __( 'A Tax rate object', 'wp-graphql-woocommercer' ),
|
||||
'interfaces' => [ WPObjectType::node_interface() ],
|
||||
'fields' => array(
|
||||
'id' => array(
|
||||
'type' => array( 'non_null' => 'ID' ),
|
||||
'description' => __( 'The globally unique identifier for the tax rate.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'rateId' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'The ID of the tax rate.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'country' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Country ISO 3166 code.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'state' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'State code.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'postcode' => array(
|
||||
'type' => array( 'list_of' => 'String' ),
|
||||
'description' => __( 'Postcode/ZIP.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'city' => array(
|
||||
'type' => array( 'list_of' => 'String' ),
|
||||
'description' => __( 'City name.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'rate' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Tax rate.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'String',
|
||||
'description' => __( 'Tax rate name.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'priority' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'Tax priority.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'compound' => array(
|
||||
'type' => 'Boolean',
|
||||
'description' => __( 'Whether or not this is a compound rate.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'shipping' => array(
|
||||
'type' => 'Boolean',
|
||||
'description' => __( 'Whether or not this tax rate also gets applied to shipping.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'order' => array(
|
||||
'type' => 'Boolean',
|
||||
'description' => __( 'Indicates the order that will appear in queries.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'class' => array(
|
||||
'type' => 'TaxClassEnum',
|
||||
'description' => __( 'Tax class. Default is standard.', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
),
|
||||
'resolve_node' => function( $node, $id, $type, AppContext $context ) {
|
||||
if ( 'tax_rate' === $type ) {
|
||||
$node = Factory::resolve_tax_rate( $id );
|
||||
}
|
||||
|
||||
return $node;
|
||||
},
|
||||
'resolve_node_type' => function( $type, $node ) {
|
||||
if ( is_a( $node, Tax_Rate::class ) ) {
|
||||
$type = 'TaxRate';
|
||||
}
|
||||
|
||||
return $type;
|
||||
},
|
||||
)
|
||||
);
|
||||
|
||||
register_graphql_field(
|
||||
'RootQuery',
|
||||
'taxRate',
|
||||
array(
|
||||
'type' => 'TaxRate',
|
||||
'description' => __( 'A tax rate object', 'wp-graphql-woocommerce' ),
|
||||
'args' => array(
|
||||
'id' => array(
|
||||
'type' => 'ID',
|
||||
'description' => __( 'Get the tax rate by its global ID', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
'rateId' => array(
|
||||
'type' => 'Int',
|
||||
'description' => __( 'Get the tax rate by its database ID', 'wp-graphql-woocommerce' ),
|
||||
),
|
||||
),
|
||||
'resolve' => function ( $source, array $args ) {
|
||||
$rate_id = 0;
|
||||
if ( ! empty( $args['id'] ) ) {
|
||||
$id_components = Relay::fromGlobalId( $args['id'] );
|
||||
if ( empty( $id_components['id'] ) || empty( $id_components['type'] ) ) {
|
||||
throw new UserError( __( 'The "id" is invalid', 'wp-graphql-woocommerce' ) );
|
||||
}
|
||||
|
||||
$arg = 'ID';
|
||||
$rate_id = absint( $id_components['id'] );
|
||||
} elseif ( ! empty( $args['rateId'] ) ) {
|
||||
$arg = 'database ID';
|
||||
$rate_id = absint( $args['rateId'] );
|
||||
}
|
||||
|
||||
return Factory::resolve_tax_rate( $rate_id );
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
+16
@@ -2511,20 +2511,26 @@ return array(
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Actions' => $baseDir . '/src/class-actions.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Coupons' => $baseDir . '/src/connection/class-coupons.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Customers' => $baseDir . '/src/connection/class-customers.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Order_Items' => $baseDir . '/src/connection/class-order-items.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Orders' => $baseDir . '/src/connection/class-orders.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Posts' => $baseDir . '/src/connection/class-posts.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Product_Attributes' => $baseDir . '/src/connection/class-product-attributes.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Products' => $baseDir . '/src/connection/class-products.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Refunds' => $baseDir . '/src/connection/class-refunds.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Shipping_Methods' => $baseDir . '/src/connection/class-shipping-methods.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Tax_Rates' => $baseDir . '/src/connection/class-tax-rates.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Connection' => $baseDir . '/src/connection/class-wc-connection.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Terms' => $baseDir . '/src/connection/class-wc-terms.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Coupon_Connection_Resolver' => $baseDir . '/src/data/connection/class-coupon-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Customer_Connection_Resolver' => $baseDir . '/src/data/connection/class-customer-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Order_Connection_Resolver' => $baseDir . '/src/data/connection/class-order-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Order_Item_Connection_Resolver' => $baseDir . '/src/data/connection/class-order-item-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Post_Connection_Resolver' => $baseDir . '/src/data/connection/class-post-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Product_Attribute_Connection_Resolver' => $baseDir . '/src/data/connection/class-product-attribute-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Product_Connection_Resolver' => $baseDir . '/src/data/connection/class-product-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Refund_Connection_Resolver' => $baseDir . '/src/data/connection/class-refund-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Shipping_Method_Connection_Resolver' => $baseDir . '/src/data/connection/class-shipping-method-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Tax_Rate_Connection_Resolver' => $baseDir . '/src/data/connection/class-tax-rate-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\WC_Connection_Resolver' => $baseDir . '/src/data/connection/trait-wc-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\WC_Terms_Connection_Resolver' => $baseDir . '/src/data/connection/class-wc-terms-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Factory' => $baseDir . '/src/data/class-factory.php',
|
||||
@@ -2536,20 +2542,28 @@ return array(
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Crud_CPT' => $baseDir . '/src/model/class-crud-cpt.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Customer' => $baseDir . '/src/model/class-customer.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Order' => $baseDir . '/src/model/class-order.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Order_Item' => $baseDir . '/src/model/class-order-item.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Product' => $baseDir . '/src/model/class-product.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Product_Variation' => $baseDir . '/src/model/class-product-variation.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Refund' => $baseDir . '/src/model/class-refund.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Shipping_Method' => $baseDir . '/src/model/class-shipping-method.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Shop_Manager_Caps' => $baseDir . '/src/model/trait-shop-manager-caps.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Tax_Rate' => $baseDir . '/src/model/class-tax-rate.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Backorders' => $baseDir . '/src/type/enum/class-backorders.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Catalog_Visibility' => $baseDir . '/src/type/enum/class-catalog-visibility.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Discount_Type' => $baseDir . '/src/type/enum/class-discount-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Manage_Stock' => $baseDir . '/src/type/enum/class-manage-stock.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Stock_Status' => $baseDir . '/src/type/enum/class-stock-status.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Class' => $baseDir . '/src/type/enum/class-tax-class.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Rate_Connection_Orderby_Enum' => $baseDir . '/src/type/enum/class-tax-rate-connection-orderby-enum.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Status' => $baseDir . '/src/type/enum/class-tax-status.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\WC_Connection_Orderby_Enum' => $baseDir . '/src/type/enum/class-wc-connection-orderby-enum.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPInputObject\\Tax_Rate_Connection_Orderby_Input' => $baseDir . '/src/type/input/class-tax-rate-connection-orderby-input.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPInputObject\\WC_Connection_Orderby_Input' => $baseDir . '/src/type/input/class-wc-connection-orderby-input.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Coupon_Type' => $baseDir . '/src/type/object/class-coupon-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Customer_Address_Type' => $baseDir . '/src/type/object/class-customer-address-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Customer_Type' => $baseDir . '/src/type/object/class-customer-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Order_Item_Type' => $baseDir . '/src/type/object/class-order-item-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Order_Type' => $baseDir . '/src/type/object/class-order-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Attribute_Type' => $baseDir . '/src/type/object/class-product-attribute-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Download_Type' => $baseDir . '/src/type/object/class-product-download-type.php',
|
||||
@@ -2557,6 +2571,8 @@ return array(
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Type' => $baseDir . '/src/type/object/class-product-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Variation_Type' => $baseDir . '/src/type/object/class-product-variation-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Refund_Type' => $baseDir . '/src/type/object/class-refund-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Shipping_Method_Type' => $baseDir . '/src/type/object/class-shipping-method-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Tax_Rate_Type' => $baseDir . '/src/type/object/class-tax-rate-type.php',
|
||||
'WP_CLI' => $vendorDir . '/wp-cli/wp-cli/php/class-wp-cli.php',
|
||||
'WP_CLI\\AutoloadSplitter' => $vendorDir . '/wp-cli/wp-cli/php/WP_CLI/AutoloadSplitter.php',
|
||||
'WP_CLI\\AutoloadSplitter\\AutoloadGenerator' => $vendorDir . '/wp-cli/autoload-splitter/src/AutoloadGenerator.php',
|
||||
|
||||
+16
@@ -2457,20 +2457,26 @@ return array(
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Actions' => $baseDir . '/src/class-actions.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Coupons' => $baseDir . '/src/connection/class-coupons.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Customers' => $baseDir . '/src/connection/class-customers.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Order_Items' => $baseDir . '/src/connection/class-order-items.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Orders' => $baseDir . '/src/connection/class-orders.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Posts' => $baseDir . '/src/connection/class-posts.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Product_Attributes' => $baseDir . '/src/connection/class-product-attributes.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Products' => $baseDir . '/src/connection/class-products.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Refunds' => $baseDir . '/src/connection/class-refunds.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Shipping_Methods' => $baseDir . '/src/connection/class-shipping-methods.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Tax_Rates' => $baseDir . '/src/connection/class-tax-rates.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Connection' => $baseDir . '/src/connection/class-wc-connection.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Terms' => $baseDir . '/src/connection/class-wc-terms.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Coupon_Connection_Resolver' => $baseDir . '/src/data/connection/class-coupon-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Customer_Connection_Resolver' => $baseDir . '/src/data/connection/class-customer-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Order_Connection_Resolver' => $baseDir . '/src/data/connection/class-order-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Order_Item_Connection_Resolver' => $baseDir . '/src/data/connection/class-order-item-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Post_Connection_Resolver' => $baseDir . '/src/data/connection/class-post-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Product_Attribute_Connection_Resolver' => $baseDir . '/src/data/connection/class-product-attribute-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Product_Connection_Resolver' => $baseDir . '/src/data/connection/class-product-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Refund_Connection_Resolver' => $baseDir . '/src/data/connection/class-refund-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Shipping_Method_Connection_Resolver' => $baseDir . '/src/data/connection/class-shipping-method-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Tax_Rate_Connection_Resolver' => $baseDir . '/src/data/connection/class-tax-rate-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\WC_Connection_Resolver' => $baseDir . '/src/data/connection/trait-wc-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\WC_Terms_Connection_Resolver' => $baseDir . '/src/data/connection/class-wc-terms-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Factory' => $baseDir . '/src/data/class-factory.php',
|
||||
@@ -2482,20 +2488,28 @@ return array(
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Crud_CPT' => $baseDir . '/src/model/class-crud-cpt.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Customer' => $baseDir . '/src/model/class-customer.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Order' => $baseDir . '/src/model/class-order.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Order_Item' => $baseDir . '/src/model/class-order-item.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Product' => $baseDir . '/src/model/class-product.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Product_Variation' => $baseDir . '/src/model/class-product-variation.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Refund' => $baseDir . '/src/model/class-refund.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Shipping_Method' => $baseDir . '/src/model/class-shipping-method.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Shop_Manager_Caps' => $baseDir . '/src/model/trait-shop-manager-caps.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Tax_Rate' => $baseDir . '/src/model/class-tax-rate.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Backorders' => $baseDir . '/src/type/enum/class-backorders.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Catalog_Visibility' => $baseDir . '/src/type/enum/class-catalog-visibility.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Discount_Type' => $baseDir . '/src/type/enum/class-discount-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Manage_Stock' => $baseDir . '/src/type/enum/class-manage-stock.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Stock_Status' => $baseDir . '/src/type/enum/class-stock-status.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Class' => $baseDir . '/src/type/enum/class-tax-class.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Rate_Connection_Orderby_Enum' => $baseDir . '/src/type/enum/class-tax-rate-connection-orderby-enum.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Status' => $baseDir . '/src/type/enum/class-tax-status.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\WC_Connection_Orderby_Enum' => $baseDir . '/src/type/enum/class-wc-connection-orderby-enum.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPInputObject\\Tax_Rate_Connection_Orderby_Input' => $baseDir . '/src/type/input/class-tax-rate-connection-orderby-input.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPInputObject\\WC_Connection_Orderby_Input' => $baseDir . '/src/type/input/class-wc-connection-orderby-input.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Coupon_Type' => $baseDir . '/src/type/object/class-coupon-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Customer_Address_Type' => $baseDir . '/src/type/object/class-customer-address-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Customer_Type' => $baseDir . '/src/type/object/class-customer-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Order_Item_Type' => $baseDir . '/src/type/object/class-order-item-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Order_Type' => $baseDir . '/src/type/object/class-order-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Attribute_Type' => $baseDir . '/src/type/object/class-product-attribute-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Download_Type' => $baseDir . '/src/type/object/class-product-download-type.php',
|
||||
@@ -2503,6 +2517,8 @@ return array(
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Type' => $baseDir . '/src/type/object/class-product-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Variation_Type' => $baseDir . '/src/type/object/class-product-variation-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Refund_Type' => $baseDir . '/src/type/object/class-refund-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Shipping_Method_Type' => $baseDir . '/src/type/object/class-shipping-method-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Tax_Rate_Type' => $baseDir . '/src/type/object/class-tax-rate-type.php',
|
||||
'WP_CLI' => $vendorDir . '/wp-cli/wp-cli/php/class-wp-cli.php',
|
||||
'WP_CLI\\AutoloadSplitter' => $vendorDir . '/wp-cli/wp-cli/php/WP_CLI/AutoloadSplitter.php',
|
||||
'WP_CLI\\AutoloadSplitter\\AutoloadGenerator' => $vendorDir . '/wp-cli/autoload-splitter/src/AutoloadGenerator.php',
|
||||
|
||||
Vendored
+16
@@ -2951,20 +2951,26 @@ class ComposerStaticInit703f21dde3c5889862ac86d8135b48b6
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Actions' => __DIR__ . '/../..' . '/src/class-actions.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Coupons' => __DIR__ . '/../..' . '/src/connection/class-coupons.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Customers' => __DIR__ . '/../..' . '/src/connection/class-customers.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Order_Items' => __DIR__ . '/../..' . '/src/connection/class-order-items.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Orders' => __DIR__ . '/../..' . '/src/connection/class-orders.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Posts' => __DIR__ . '/../..' . '/src/connection/class-posts.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Product_Attributes' => __DIR__ . '/../..' . '/src/connection/class-product-attributes.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Products' => __DIR__ . '/../..' . '/src/connection/class-products.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Refunds' => __DIR__ . '/../..' . '/src/connection/class-refunds.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Shipping_Methods' => __DIR__ . '/../..' . '/src/connection/class-shipping-methods.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\Tax_Rates' => __DIR__ . '/../..' . '/src/connection/class-tax-rates.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Connection' => __DIR__ . '/../..' . '/src/connection/class-wc-connection.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Connection\\WC_Terms' => __DIR__ . '/../..' . '/src/connection/class-wc-terms.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Coupon_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-coupon-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Customer_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-customer-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Order_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-order-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Order_Item_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-order-item-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Post_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-post-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Product_Attribute_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-product-attribute-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Product_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-product-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Refund_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-refund-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Shipping_Method_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-shipping-method-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\Tax_Rate_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-tax-rate-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\WC_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/trait-wc-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Connection\\WC_Terms_Connection_Resolver' => __DIR__ . '/../..' . '/src/data/connection/class-wc-terms-connection-resolver.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Data\\Factory' => __DIR__ . '/../..' . '/src/data/class-factory.php',
|
||||
@@ -2976,20 +2982,28 @@ class ComposerStaticInit703f21dde3c5889862ac86d8135b48b6
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Crud_CPT' => __DIR__ . '/../..' . '/src/model/class-crud-cpt.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Customer' => __DIR__ . '/../..' . '/src/model/class-customer.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Order' => __DIR__ . '/../..' . '/src/model/class-order.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Order_Item' => __DIR__ . '/../..' . '/src/model/class-order-item.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Product' => __DIR__ . '/../..' . '/src/model/class-product.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Product_Variation' => __DIR__ . '/../..' . '/src/model/class-product-variation.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Refund' => __DIR__ . '/../..' . '/src/model/class-refund.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Shipping_Method' => __DIR__ . '/../..' . '/src/model/class-shipping-method.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Shop_Manager_Caps' => __DIR__ . '/../..' . '/src/model/trait-shop-manager-caps.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Model\\Tax_Rate' => __DIR__ . '/../..' . '/src/model/class-tax-rate.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Backorders' => __DIR__ . '/../..' . '/src/type/enum/class-backorders.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Catalog_Visibility' => __DIR__ . '/../..' . '/src/type/enum/class-catalog-visibility.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Discount_Type' => __DIR__ . '/../..' . '/src/type/enum/class-discount-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Manage_Stock' => __DIR__ . '/../..' . '/src/type/enum/class-manage-stock.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Stock_Status' => __DIR__ . '/../..' . '/src/type/enum/class-stock-status.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Class' => __DIR__ . '/../..' . '/src/type/enum/class-tax-class.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Rate_Connection_Orderby_Enum' => __DIR__ . '/../..' . '/src/type/enum/class-tax-rate-connection-orderby-enum.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\Tax_Status' => __DIR__ . '/../..' . '/src/type/enum/class-tax-status.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPEnum\\WC_Connection_Orderby_Enum' => __DIR__ . '/../..' . '/src/type/enum/class-wc-connection-orderby-enum.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPInputObject\\Tax_Rate_Connection_Orderby_Input' => __DIR__ . '/../..' . '/src/type/input/class-tax-rate-connection-orderby-input.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPInputObject\\WC_Connection_Orderby_Input' => __DIR__ . '/../..' . '/src/type/input/class-wc-connection-orderby-input.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Coupon_Type' => __DIR__ . '/../..' . '/src/type/object/class-coupon-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Customer_Address_Type' => __DIR__ . '/../..' . '/src/type/object/class-customer-address-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Customer_Type' => __DIR__ . '/../..' . '/src/type/object/class-customer-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Order_Item_Type' => __DIR__ . '/../..' . '/src/type/object/class-order-item-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Order_Type' => __DIR__ . '/../..' . '/src/type/object/class-order-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Attribute_Type' => __DIR__ . '/../..' . '/src/type/object/class-product-attribute-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Download_Type' => __DIR__ . '/../..' . '/src/type/object/class-product-download-type.php',
|
||||
@@ -2997,6 +3011,8 @@ class ComposerStaticInit703f21dde3c5889862ac86d8135b48b6
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Type' => __DIR__ . '/../..' . '/src/type/object/class-product-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Product_Variation_Type' => __DIR__ . '/../..' . '/src/type/object/class-product-variation-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Refund_Type' => __DIR__ . '/../..' . '/src/type/object/class-refund-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Shipping_Method_Type' => __DIR__ . '/../..' . '/src/type/object/class-shipping-method-type.php',
|
||||
'WPGraphQL\\Extensions\\WooCommerce\\Type\\WPObject\\Tax_Rate_Type' => __DIR__ . '/../..' . '/src/type/object/class-tax-rate-type.php',
|
||||
'WP_CLI' => __DIR__ . '/..' . '/wp-cli/wp-cli/php/class-wp-cli.php',
|
||||
'WP_CLI\\AutoloadSplitter' => __DIR__ . '/..' . '/wp-cli/wp-cli/php/WP_CLI/AutoloadSplitter.php',
|
||||
'WP_CLI\\AutoloadSplitter\\AutoloadGenerator' => __DIR__ . '/..' . '/wp-cli/autoload-splitter/src/AutoloadGenerator.php',
|
||||
|
||||
Reference in New Issue
Block a user