Skip to content

Commit

Permalink
Update class-root-query.php (#584)
Browse files Browse the repository at this point in the history
Fix for bug #583.
  • Loading branch information
stevezehngut authored Dec 7, 2021
1 parent be38f29 commit d020328
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions includes/type/object/class-root-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 ) );
Expand Down

0 comments on commit d020328

Please sign in to comment.