【问题标题】:Shopify GraphQL to fetch Delivery Rate for ProductsShopify GraphQL 以获取产品的交付率
【发布时间】:2020-09-04 18:59:58
【问题描述】:

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

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

我正在使用的当前查询:

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

【问题讨论】:

    标签: graphql shopify shipping shopify-api


    【解决方案1】:

    想通了。这只是理解嵌套的问题。以下是您在 Shopify 中使用 GraphQL API 获取产品和运费的方法:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-31
      • 2020-09-28
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      • 2012-06-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多