From d020328133570686a6c3e8ff3d14fc1fe64612b3 Mon Sep 17 00:00:00 2001 From: stevezehngut Date: Tue, 7 Dec 2021 13:45:54 -0800 Subject: [PATCH] Update class-root-query.php (#584) Fix for bug #583. --- includes/type/object/class-root-query.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/type/object/class-root-query.php b/includes/type/object/class-root-query.php index 47c3ee0eb..5c39867b5 100644 --- a/includes/type/object/class-root-query.php +++ b/includes/type/object/class-root-query.php @@ -450,7 +450,7 @@ public static function register_fields() { 'description' => __( 'Type of ID being used identify product', 'wp-graphql-woocommerce' ), ), ), - 'resolve' => function ( $source, array $args, AppContext $context, ResolveInfo $info ) use ( $type_name ) { + 'resolve' => function ( $source, array $args, AppContext $context, ResolveInfo $info ) use ( $type_key ) { $id = isset( $args['id'] ) ? $args['id'] : null; $id_type = isset( $args['idType'] ) ? $args['idType'] : 'global_id'; @@ -479,9 +479,9 @@ public static function register_fields() { if ( empty( $product_id ) ) { /* translators: %1$s: ID type, %2$s: ID value */ throw new UserError( sprintf( __( 'No product ID was found corresponding to the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $product_id ) ); - } elseif ( \WC()->product_factory->get_product_type( $product_id ) !== $type_name ) { + } elseif ( \WC()->product_factory->get_product_type( $product_id ) !== $type_key ) { /* translators: Invalid product type message %1$s: Product ID, %2$s: Product type */ - throw new UserError( sprintf( __( 'This product of ID %1$s is not a %2$s product', 'wp-graphql-woocommerce' ), $product_id, $type_name ) ); + throw new UserError( sprintf( __( 'This product of ID %1$s is not a %2$s product', 'wp-graphql-woocommerce' ), $product_id, $type_key ) ); } elseif ( get_post( $product_id )->post_type !== 'product' ) { /* translators: %1$s: ID type, %2$s: ID value */ throw new UserError( sprintf( __( 'No product exists with the %1$s: %2$s', 'wp-graphql-woocommerce' ), $id_type, $product_id ) );