Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.
Solved

Issue with orderUpdate GraphQL Mutation: shippingAddress.phone Field

seb21
Shopify Partner
5 0 1

Hi,

 

I encountered a puzzling issue with the orderUpdate GraphQL mutation (docs here). The shippingAddress.phone field, as per the documentation, isn't flagged as required, but sporadically I'm getting an "Enter a phone number" error.

Oddly, I can't replicate this myself, but my logs reveal that some API calls, executed on behalf of customers via our Shopify app, trigger this error. Any idea why I'm getting this error please?

 

Here is the request:

{
    "query": "mutation orderUpdate($input: OrderInput!) {
                  orderUpdate(input: $input) {
                      order {
                          id
                      }
                      userErrors {
                          field
                          message
                      }
                  }
              }",
    "operationName": "orderUpdate",
    "variables": {
      "input": {
        "id": "gid://shopify/Order/** REDACTED **",
        "shippingAddress": {
          "firstName": "** REDACTED **",
          "lastName": "** REDACTED **",
          "address1": "** REDACTED **",
          "address2": "** REDACTED **",
          "city": "Auckland",
          "zip": "1010",
          "province": null,
          "company": null,
          "countryCode": "NZ"
        },
        "customAttributes": []
      }
    }
  }

And the response:

{
    "data": {
      "orderUpdate": {
        "order": { "id": "gid://shopify/Order/** REDACTED **" },
        "userErrors": [
          {
            "field": ["shippingAddress", "phone"],
            "message": "Enter a phone number"
          }
        ]
      },
      "extensions": {
        "cost": {
          "requestedQueryCost": 10,
          "actualQueryCost": 10,
          "throttleStatus": {
            "maximumAvailable": 1000.0,
            "currentlyAvailable": 990,
            "restoreRate": 50.0
          }
        }
      }
    }
  }
  

 

Thanks

Seb

Accepted Solution (1)
SBD_
Shopify Staff
1776 263 383

This is an accepted solution.

Hey @seb21 

 

From the Orders team:

 

---

 

Our logs indicate the gateway or checkout settings may dictate whether or not a phone number is required.

In the store provided by the Partner, it can be seen that they have phone number set to required in their checkout settings. This is likely the reason why the partner saw the error in that one request.

I was able to reproduce it on my test store by:
  1. Set require phone number in my checkouts settings
  2. Create a draft order with no customer and mark as paid
  3. Run the GQL query provided by the partner against the order to update the shippingAddress without a phone

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 7 (7)

SBD_
Shopify Staff
1776 263 383

Hey @seb21 

 

Checking with the Orders team and will report back!

Scott | Developer Advocate @ Shopify 

SBD_
Shopify Staff
1776 263 383

Hey @seb21 

 

Are you able to capture a request ID from one of the `Enter a phone number` responses?

Scott | Developer Advocate @ Shopify 

seb21
Shopify Partner
5 0 1

Hi Scott, here is a complete response with headers:

200 OK OK
Date: Thu, 18 Jan 2024 02:37:23 GMT
Transfer-Encoding: chunked
Connection: keep-alive
X-Sorting-Hat-PodId: 303
X-Sorting-Hat-ShopId: ** REDACTED **
Vary: Accept-Encoding
Referrer-Policy: origin-when-cross-origin
X-Frame-Options: DENY
x-shopid: ** REDACTED **
x-shardid: 303
x-stats-userid: 
x-stats-apiclientid: ** REDACTED **
x-stats-apipermissionid: ** REDACTED **
x-shopify-api-version: 2023-07
x-shopify-api-deprecated-reason: https://shopify.dev/api/usage/versioning#deprecation-practices
Strict-Transport-Security: max-age=7889238
Server-Timing: processing;dur=112, graphql;desc="admin/mutation/other";cfRequestDuration;dur=327.999830
x-shopify-stage: production
Content-Security-Policy: default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval' https://* shopify-pos://*; block-all-mixed-content; child-src 'self' https://* shopify-pos://*; connect-src 'self' wss://* https://*; frame-ancestors 'none'; img-src 'self' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopifycdn.net https://checkout.shopifycs.com https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com 'self' 'unsafe-inline' 'unsafe-eval'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=query&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fgraphql&source%5Bsection%5D=admin_api&source%5Buuid%5D=28d38950-a394-4b42-8b22-631cec53e48f
X-Content-Type-Options: nosniff
x-download-options: noopen
x-permitted-cross-domain-policies: none
X-XSS-Protection: 1; mode=block; report=/xss-report?source%5Baction%5D=query&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fgraphql&source%5Bsection%5D=admin_api&source%5Buuid%5D=28d38950-a394-4b42-8b22-631cec53e48f
x-envoy-upstream-service-time: 114
X-Dc: gcp-australia-southeast1,gcp-us-central1
X-Request-ID: 28d38950-a394-4b42-8b22-631cec53e48f
CF-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=DVUs0QfUl3KYoohgUK1fVXPJ0rWRFSUW9IHKnP58wUy6YmH%2FPLZkBbO6XyeJlExYaa5bbU%2FjbvHdWL1rj%2BhbhnIw9OiV%2BzrJzc7NU1OFyCA5KiOULRYiSnKTWYnIpy%2BdYDFYBcR8wC8%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 847374aaf8935d18-SYD
Alt-Svc: h3=":443"

{
  "data": {
    "orderUpdate": {
      "order": { "id": "gid://shopify/Order/** REDACTED **" },
      "userErrors": [
        {
          "field": ["shippingAddress", "phone"],
          "message": "Enter a phone number"
        }
      ]
    },
    "extensions": {
      "cost": {
        "requestedQueryCost": 10,
        "actualQueryCost": 10,
        "throttleStatus": {
          "maximumAvailable": 1000.0,
          "currentlyAvailable": 990,
          "restoreRate": 50.0
        }
      }
    }
  }
}

 If you need any of the redacted values please let me know if they're safe to post here or let know how I can private message you.

SBD_
Shopify Staff
1776 263 383

Amazing, thanks @seb21 - passing this on to the team.

Scott | Developer Advocate @ Shopify 

seb21
Shopify Partner
5 0 1

Hi Scott, any progress on this please?

SBD_
Shopify Staff
1776 263 383

This is an accepted solution.

Hey @seb21 

 

From the Orders team:

 

---

 

Our logs indicate the gateway or checkout settings may dictate whether or not a phone number is required.

In the store provided by the Partner, it can be seen that they have phone number set to required in their checkout settings. This is likely the reason why the partner saw the error in that one request.

I was able to reproduce it on my test store by:
  1. Set require phone number in my checkouts settings
  2. Create a draft order with no customer and mark as paid
  3. Run the GQL query provided by the partner against the order to update the shippingAddress without a phone

Scott | Developer Advocate @ Shopify 

seb21
Shopify Partner
5 0 1

Thanks Scott, I appreciate you getting back to me. I can replicate with your steps above too. I'll fix the issue with a validation error in our UI.