首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用GraphQL获取产品的交货率

使用GraphQL获取产品的交货率
EN

Stack Overflow用户
提问于 2020-09-04 18:59:58
回答 1查看 929关注 0票数 0

我正在尝试从deliveryProfiles对象(或配送配置文件)中获取产品及其交付率。使用下面的查询,我能够提取与deliveryProfile相关的所有产品,但我无法弄清楚如何获取每个产品的交付率。我们的商店只使用静态运费,所以我相信我需要使用类似下面的rateProvider查询。但我不知道,甚至不知道如何修改查询,以包括这样的内容。

代码语言:javascript
复制
rateProvider {... on DeliveryRateDefinition {id price {amount}

我正在使用的当前查询:

代码语言:javascript
复制
query {
  deliveryProfiles (first: 5) {
    edges {
      node {
        profileItems (first: 10) {
          edges {
            node {
              product {
                  id
                  handle
              }
              variants (first: 10) {
                edges {
                  node {
                    id
                    title
                    sku
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-07 21:30:02

弄明白了。这只是一个理解嵌套的问题。下面是如何使用GraphQL API在Shopify中获取产品和交付率:

代码语言:javascript
复制
query {
  deliveryProfiles (first: 2) {
    edges {
      node {
        profileItems (first: 8) {
          edges {
            node {
              product {
                id
                handle
              }
              variants (first: 8) {
                edges {
                  node {
                    id
                    title
                  }
                }
              }
            }
          }
        }
        profileLocationGroups {
          locationGroupZones(first: 2) {
            edges {
              node {
                methodDefinitions(first: 2) {
                  edges {
                    node {
                      rateProvider {
                        ... on DeliveryRateDefinition {
                          id
                          price {
                            amount
                          }
                        }
                        ... on DeliveryParticipant {
                          id
                          fixedFee {
                            amount
                            currencyCode
                          }
                          percentageOfRateFee
                          participantServices {
                            active
                            name
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }        
      }
    }
  }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63746709

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档