Solved

Checkout object returns null for certain fields even though webUrl has information

sam-parks
Tourist
7 0 1

After using the checkoutShippingLineUpdate mutation or the appendGiftCardMutation, the checkout object returned from this mutation: 

query($id: ID!){
  node(id: $id) {
    ... on Checkout {
      id
      email
      appliedGiftCards {
        amountUsedV2 {
          amount
          currencyCode
        }
        balanceV2 {
          amount
          currencyCode
        }
        id
      }
      requiresShipping
      shippingLine {
        handle
        priceV2 {
          amount
          currencyCode
        }
        title
      }
      availableShippingRates {
        ready
        shippingRates {
          handle
          title
          priceV2 {
            amount
            currencyCode
          }
        }
      }
      shippingAddress {
        address1
        address2
        city
        company
        country
        countryCodeV2
        firstName
        formattedArea
        id
        lastName
        latitude
        longitude
        name
        phone
        province
        provinceCode
        zip
      }
      completedAt
      createdAt
      currencyCode
      lineItems(first: 10) {
        edges {
          node {
            id
            quantity
            title
            discountAllocations {
              allocatedAmount {
                amount
                currencyCode
              }
            }
            variant {
              id
              priceV2 {
                amount
                currencyCode
              }
              title
              image {
                altText
                originalSrc
                id
              }
              compareAtPriceV2 {
                amount
                currencyCode
              }
              weight
              weightUnit
              availableForSale
              sku
              requiresShipping
            }
          }
        }
      }
      note
      webUrl
      updatedAt
      totalTaxV2 {
        amount
        currencyCode
      }
      totalPriceV2 {
        amount
        currencyCode
      }
      taxesIncluded
      taxExempt
      subtotalPriceV2 {
        amount
        currencyCode
      }
      orderStatusUrl
      order {
        id
      }
    }
  }
}

 

does not have any applied gift cards and the shipping line is null

When I navigate to the weburl for this checkout, I can see that the gift cards have been applied and that a shipping line is selected.

Why does the checkout object not have the information for these corresponding fields?

 

 

Accepted Solution (1)
_JCC_
Shopify Staff
200 27 55

This is an accepted solution.

Hey @sam-parks ,

In our logs I'm not seeing a subsequent query for the checkout after the checkoutShippingLineUpdate. For the checkout id provided I am seeing the query happening after an address update which does reset the shipping line to null.

If you take the checkout id provided in your earlier reply and just try that query with Insomnia or Postman do you see same where the shipping line is still null?

Regards,
John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 10 (10)

_JCC_
Shopify Staff
200 27 55

Hey @sam-parks ,

Depending on the configuration of the store it's possible some of the calculations involved with a modification of the checkout are happening async. On the Checkout object there's a ready field that can be used to determine if the checkout is in a state to be completed. In the event the ready field does not returning as true in the response from the mutations mentioned, you can query the checkout object at an interval of your choosing to determine when all calculations have been completed.

I hope this helps, if you have any other questions please don't hesitate to reach out.

Regards,

John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

sam-parks
Tourist
7 0 1

@_JCC_ 

Ok going off of that I have a couple of more questions:

- Do you have webhooks for listening to Checkout objects? 

- On what time scale do these calculations take? (milliseconds, seconds, mins)

- Is there a reason why the Shopify API works this way instead of sending an updated checkout object when applying a gift card or shipping line? 

_JCC_
Shopify Staff
200 27 55

Hey @sam-parks ,

We do support web hooks for checkout actions like create, update and delete.

In my own testing I haven't seen these calculations take longer than a couple of seconds. That being said, server load, and factors like using external tax engines or external shipping rates pulled through using Carrier service API can impact these times.

The intent is too quickly provide a response to your initial request, while also communicating that calculations are not complete. In particular mutations affecting the checkout total like selecting a shipping line or adding a discounts need to re-calculate things like taxes so we prefer to handle those operations async and provide a means for your to know when they are complete.

I do have a recorded issue on this point as I can see the opinion that the async approach isn't ideal for everyone so this could possibly change in the future, I just don't have a timeline on if or when that might happen.

Regards,

John

 

 

 

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

sam-parks
Tourist
7 0 1

@_JCC_ 

I am receiving a null value for shippingLine even though the checkout object is ready and I have made a request to checkoutShippingLineUpdate with a 200 response. 

 

Screen Shot 2021-06-30 at 2.29.51 PM.png

Are there other reasons why this value might be null?

.

_JCC_
Shopify Staff
200 27 55

Hey @sam-parks

I apologize for the lateness in my reply. When receiving the response to the shippingLineUpdate mutation if you were to make a subsequent query of the checkout does the shipping line in that response show up as populated? 

For example to query the checkout,

 

query getCheckout ($checkoutId:ID!){
  
  node(id: $checkoutId) {
    ... on Checkout {
      id
      ready
      webUrl
      email
      lineItems(first:10){
        edges{
          node{
            id
            quantity
          }
        }
      }
      shippingAddress{
        address1
        city
        zip
      }
      shippingLine{
        handle
        priceV2{
          amount
        }
      }
   }
 } 
}

 

I look forward to hearing back from you, and on the subsequent reply if you could provide the checkout id used in your more recent test I'll have a look at our logs with that.

Warm Regards,
John Cole | Developer Support

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

sam-parks
Tourist
7 0 1

Here is the subsequent query:

query($id: ID!){
  node(id: $id) {
    ... on Checkout {
      id
      email
      ready
      appliedGiftCards {
        amountUsedV2 {
          amount
          currencyCode
        }
        balanceV2 {
          amount
          currencyCode
        }
        id
      }
      requiresShipping
      shippingLine {
        handle
        priceV2 {
          amount
          currencyCode
        }
        title
      }
      shippingAddress {
        address1
        address2
        city
        company
        country
        countryCodeV2
        firstName
        formattedArea
        id
        lastName
        latitude
        longitude
        name
        phone
        province
        provinceCode
        zip
      }
      completedAt
      createdAt
      currencyCode
      lineItems(first: 10) {
        edges {
          node {
            id
            quantity
            title
             discountAllocations {
              allocatedAmount {
                amount
                currencyCode
              }
            }
            variant {
              id
              priceV2 {
                amount
                currencyCode
              }
              title
              image {
                altText
                originalSrc
                id
              }
              compareAtPriceV2 {
                amount
                currencyCode
              }
              weight
              weightUnit
              availableForSale
              sku
              requiresShipping
            }
          }
        }
      }
      note
      webUrl
      updatedAt
      totalTaxV2 {
        amount
        currencyCode
      }
      totalPriceV2 {
        amount
        currencyCode
      }
      taxesIncluded
      taxExempt
      subtotalPriceV2 {
        amount
        currencyCode
      }
      orderStatusUrl
      order {
        id
      }
    }
  }
}

 

Here is the checkout id: Z2lkOi8vc2hvcGlmeS9DaGVja291dC8yZWI3OWUwNjdjM2RkM2Q4YzJjMDZjNTAxNWRmYWIxMD9rZXk9YzA3N2VhYWVmMDVmZWM5YzE0NWJlNjA0NmUxNDM3OWI=

_JCC_
Shopify Staff
200 27 55

Hey @sam-parks ,

Thanks for providing that checkout id. Did the shipping line show in the response to that subsequent checkout query after you set the shipping line with the checkoutShippingLineUpdate mutation?

Regards,

John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

sam-parks
Tourist
7 0 1

No, shippingLine was null.

_JCC_
Shopify Staff
200 27 55

This is an accepted solution.

Hey @sam-parks ,

In our logs I'm not seeing a subsequent query for the checkout after the checkoutShippingLineUpdate. For the checkout id provided I am seeing the query happening after an address update which does reset the shipping line to null.

If you take the checkout id provided in your earlier reply and just try that query with Insomnia or Postman do you see same where the shipping line is still null?

Regards,
John

John C | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

sam-parks
Tourist
7 0 1

I was using a separate request to get the updated checkout information rather than using the shipping line mutation to get the updated checkout object. When I return all the info from the mutation, I seem to be getting the up to date object!