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.

Shopify GraphQL to fetch Delivery Rate for Products

upc278999
Tourist
9 0 1

I'm trying to fetch products and their delivery rates from the [deliveryProfiles] object (or shipping profiles). Using the second query below I am able to pull all products that are associated with a [deliveryProfile] but I can't figure out how to fetch the Delivery Rate for each product. Our store only uses static shipping rates so I believe I need to use something like the [rateProvider] query below. But I don't know or even how to modified the query to include something like this:

 

rateProvider {
... on DeliveryRateDefinition {
                       id
                       price {
                            amount
                     }

 

Current query I'm using:

 

query {
  deliveryProfiles (first: 5) {
    edges {
      node {
        profileItems (first: 10) {
          edges {
            node {
              product {
                  id
                  handle
              }
              variants (first: 10) {
                edges {
                  node {
                    id
                    title
                    sku
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

 

Reply 1 (1)

upc278999
Tourist
9 0 1

Figured it out. Here's the solution:

query {
  deliveryProfiles (first: 5) {
    edges {
      node {
        profileItems (first: 5) {
          edges {
            node {
              product {
                id
                handle
              }
              variants (first: 5) {
                edges {
                  node {
                    id
                    title
                  }
                }
              }
            }
          }
        }
        profileLocationGroups {
          locationGroupZones(first: 5) {
            edges {
              node {
                methodDefinitions(first: 5) {
                  edges {
                    node {
                      rateProvider {
                        ... on DeliveryRateDefinition {
                          id
                          price {
                            amount
                          }
                        }
                        ... on DeliveryParticipant {
                          id
                          fixedFee {
                            amount
                            currencyCode
                          }
                          percentageOfRateFee
                          participantServices {
                            active
                            name
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }        
      }
    }
  }
}