Skip to content

Order query with idType: ORDER_NUMBER actually expects orderKey instead of orderNumber #679

Closed
@j-miguel

Description

@j-miguel

When I try to run the Order query passing an orderNumber as id

order(idType: ORDER_NUMBER, id: "123") {
    orderNumber
    orderKey
  }

I get an error: "No order ID was found corresponding to the order_number: 123"

If I pass an orderKey instead:

order(idType: ORDER_NUMBER, id: "wc_order_Zjd4Iusj4poZ") {
    orderNumber
    orderKey
  }

I get the wanted response:

{
    "order": {
      "orderNumber": "123",
      "orderKey": "wc_order_Zjd4Iusj4poZ"
    }
}

Looking at the code, I've found the step where this check is executed:

switch ( $id_type ) {
case 'order_number':
$order_id = \wc_get_order_id_by_order_key( $id );
break;

To query by the orderNumber,this would have to change for a orderNumber "lookup".

If passing the orderKey is the expected behaviour, I suppose changing the idType to ORDER_KEY would avoid this confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions