Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Shopify GraphQL to fetch Delivery Rate for Products

Shopify GraphQL to fetch Delivery Rate for Products

upc278999
Tourist
9 0 3

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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

 

Replies 2 (2)

upc278999
Tourist
9 0 3

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
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }        
      }
    }
  }
}

 

PongTan
Shopify Partner
1 0 0

It's work. Thank you!!