mirror of
https://github.com/wp-graphql/wp-graphql-woocommerce.git
synced 2026-08-14 12:53:44 +02:00
"ProductTaxonomyEnum" updated.
This commit is contained in:
@@ -51,7 +51,7 @@ class Factory {
|
||||
}
|
||||
$customer_id = absint( $id );
|
||||
$loader = $context->getLoader( 'wc_customer' );
|
||||
$loader->buffer( [ $customer_id ] );
|
||||
$loader->buffer( array( $customer_id ) );
|
||||
return new Deferred(
|
||||
function () use ( $loader, $customer_id ) {
|
||||
return $loader->load( $customer_id );
|
||||
@@ -74,7 +74,7 @@ class Factory {
|
||||
}
|
||||
$object_id = absint( $id );
|
||||
$loader = $context->getLoader( 'wc_post_crud' );
|
||||
$loader->buffer( [ $object_id ] );
|
||||
$loader->buffer( array( $object_id ) );
|
||||
return new Deferred(
|
||||
function () use ( $loader, $object_id ) {
|
||||
return $loader->load( $object_id );
|
||||
|
||||
@@ -147,7 +147,7 @@ class Product_Connection_Resolver extends AbstractConnectionResolver {
|
||||
/**
|
||||
* Collect the input_fields and sanitize them to prepare them for sending to the WP_Query
|
||||
*/
|
||||
$input_fields = [];
|
||||
$input_fields = array();
|
||||
if ( ! empty( $this->args['where'] ) ) {
|
||||
$input_fields = $this->sanitize_input_fields( $this->args['where'] );
|
||||
}
|
||||
|
||||
@@ -24,18 +24,25 @@ class Product_Taxonomy {
|
||||
$attribute_values[ WPEnumType::get_safe_name( $attribute ) ] = array( 'value' => $attribute );
|
||||
}
|
||||
|
||||
// Get values from taxonomies connected to products.
|
||||
$taxonomy_values = array();
|
||||
$allowed_taxonomies = \WPGraphQL::get_allowed_taxonomies();
|
||||
if ( ! empty( $allowed_taxonomies && is_array( $allowed_taxonomies ) ) ) {
|
||||
foreach ( $allowed_taxonomies as $taxonomy ) {
|
||||
$tax_object = get_taxonomy( $taxonomy );
|
||||
if ( in_array( $post_type, $tax_object->object_type, true ) ) {
|
||||
$taxonomy_values[ WPEnumType::get_safe_name( $tax_object->graphql_single_name ) ] = array( 'value' => $taxonomy );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
register_graphql_enum_type(
|
||||
'ProductTaxonomyEnum',
|
||||
array(
|
||||
'description' => __( 'Product taxonomies', 'wp-graphql-woocommerce' ),
|
||||
'values' => array_merge(
|
||||
array(
|
||||
'TYPE' => array( 'value' => 'product_type' ),
|
||||
'CATEGORY' => array( 'value' => 'product_cat' ),
|
||||
'TAG' => array( 'value' => 'product_tag' ),
|
||||
'BRAND' => array( 'value' => 'product_brand' ),
|
||||
),
|
||||
$attribute_values
|
||||
$attribute_values,
|
||||
$taxonomy_values,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user