Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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