Estimated Delivery Dates from API like in Checkout

Estimated Delivery Dates from API like in Checkout

IQAir_Developer
Shopify Partner
8 0 3

In our checkout we setup Estimated Delivery Dates (EDD). You can see these in the screenshot below.

 

Screen Shot 2022-12-15 at 6.42.26 AM.png

I would like to get these estimated delivery dates from the API, if possible. Here's what I've tried so far.

 

I'm using the unstable version of the Storefront API. Specifically, this section https://shopify.dev/api/storefront/unstable/objects/CartDeliveryOption for Cart > CartDeliveryOption. Here there are two fields maxEstimatedDeliveryDate and minEstimatedDeliveryDate. From what I can tell these are the same fields that should have the data about EDD. I enabled processing time and I have flat rate shipping setup and carrier shipping types, which you can see in the screenshot above.

 

(Side note: I'm using the unstable version of the API because the current and RC version do not have the EDD fields).

 

My GraphQL query looks like this:

 

[Storefront API]

[Version: unstable]

 

mutation {
  cartCreate(input: {lines: [{quantity: 1, merchandiseId: "gid://shopify/ProductVariant/40266837491794"}], buyerIdentity: {email: "noodlesthetalkingpoodle@gmail.com", deliveryAddressPreferences: {deliveryAddress: {address1: "14351 Firestone Blvd", address2: "", city: "La Mirada", company: "", firstName: "Anthony", lastName: "F", country: "USA", phone: "555-888-1100", province: "California", zip: "90638"}}}, attributes: {key: "cart_attribute", value: "This is a cart attribute"}}) {
    cart {
      id
      createdAt
      updatedAt
      note
      lines(first: 10) {
        edges {
          node {
            id
            merchandise {
              ... on ProductVariant {
                id
              }
            }
          }
        }
      }
      attributes {
        key
        value
      }
      cost {
        totalAmount {
          amount
          currencyCode
        }
        subtotalAmount {
          amount
          currencyCode
        }
        totalTaxAmount {
          amount
          currencyCode
        }
        totalDutyAmount {
          amount
          currencyCode
        }
      }
      deliveryGroups(first: 30) {
        edges {
          node {
            id
            deliveryOptions {
            	description
              handle
              code
              maxEstimatedDeliveryDate
              minEstimatedDeliveryDate
              deliveryMethodType
              title
              estimatedCost {
                amount
              }
            }
          }
        }
      }
      buyerIdentity {
        countryCode
        email
        deliveryAddressPreferences {
          __typename
        }
      }
    }
  }
}

And here's the result:

{
  "data": {
    "cartCreate": {
      "cart": {
        "id": "gid://shopify/Cart/bb5610837ab9c80d71f7f46454ff02f5",
        "createdAt": "2022-12-15T14:40:16Z",
        "updatedAt": "2022-12-15T14:40:17Z",
        "note": null,
        "lines": {
          "edges": [
            {
              "node": {
                "id": "gid://shopify/CartLine/8cc9154f-4790-43e4-b6cf-ea88af12df38?cart=bb5610837ab9c80d71f7f46454ff02f5",
                "merchandise": {
                  "id": "gid://shopify/ProductVariant/40266837491794"
                }
              }
            }
          ]
        },
        "attributes": [
          {
            "key": "cart_attribute",
            "value": "This is a cart attribute"
          }
        ],
        "cost": {
          "totalAmount": {
            "amount": "139.5",
            "currencyCode": "USD"
          },
          "subtotalAmount": {
            "amount": "134.5",
            "currencyCode": "USD"
          },
          "totalTaxAmount": null,
          "totalDutyAmount": null
        },
        "deliveryGroups": {
          "edges": [
            {
              "node": {
                "id": "gid://shopify/CartDeliveryGroup/afcc5dc3ce6a71bb658832fb61fc6016?cart=bb5610837ab9c80d71f7f46454ff02f5",
                "deliveryOptions": [
                  {
                    "description": null,
                    "handle": "4feee81826670e7c31b0ba91dca9231d",
                    "code": "Free Ground Shipping on Orders $250+ --- 5DOLLARS",
                    "maxEstimatedDeliveryDate": null,
                    "minEstimatedDeliveryDate": null,
                    "deliveryMethodType": "SHIPPING",
                    "title": "Free Ground Shipping on Orders $250+ --- 5DOLLARS",
                    "estimatedCost": {
                      "amount": "5.0"
                    }
                  },
                  {
                    "description": null,
                    "handle": "4110a276b5c71b47371b93780da3f10d",
                    "code": "Free Ground Shipping on Orders $250+ --- 15DOLLARS",
                    "maxEstimatedDeliveryDate": null,
                    "minEstimatedDeliveryDate": null,
                    "deliveryMethodType": "SHIPPING",
                    "title": "Free Ground Shipping on Orders $250+ --- 15DOLLARS",
                    "estimatedCost": {
                      "amount": "15.0"
                    }
                  },
                  {
                    "description": null,
                    "handle": "2239594c779c7537661c0e8103362ae9",
                    "code": "McShipping",
                    "maxEstimatedDeliveryDate": null,
                    "minEstimatedDeliveryDate": null,
                    "deliveryMethodType": "SHIPPING",
                    "title": "McShipping",
                    "estimatedCost": {
                      "amount": "20.0"
                    }
                  }
                ]
              }
            }
          ]
        },
        "buyerIdentity": {
          "countryCode": "US",
          "email": "noodlesthetalkingpoodle@gmail.com",
          "deliveryAddressPreferences": [
            {
              "__typename": "MailingAddress"
            }
          ]
        }
      }
    }
  }
}

There are a few things to note here:

- None of the carrier shipping methods are returned in the result.

- In the returned results, the value of the max and min EDD is null -- this is expected since it's not showing on the Checkout page either.

 

My next option would be to try and work with the carrier API directly, but it would be nice to keep everything coming from one API.

 

I appreciate any feedback.

 

Anthony

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 508

Hey Anthony,

 

Thanks for the post! 

 

The CartDelivery option specific to maxEstimatedDeliveryDate and minEstimatedDeliveryDate are dependent on having processing times set up for the store and meeting all the conditions.

 

You may want to review the conditions and make sure you have met them all - if one of the checkouts is showing a mix of eligible and ineligible rates, then it will return 'NULL' for all. 

 

If that doesn't work, please feel free to reach out to our partner support and provide authenticated details on the store in question and we can have a closer look.

 

Thanks. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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