我已经在Shopify中创建了一个试用帐户,并添加了一些产品。我试图在我的android应用上显示这些产品并购买。这些产品属于“新闻文章”类,用户可以购买一次并在需要时阅读。https://insightmy.myshopify.com/products.json(它们具有虚拟内容,仅用于学习目的)final ID id = new ID("72355741740");Storefront.QueryRootQuery query2 = Storefront.query(newStorefront.QueryRootQueryDefinition() {@Overridepublic void define(Storefront.QueryRootQuery _queryBuilder) { _queryBuilder.node(id, new Storefront.NodeQueryDefinition() { @Override public void define(NodeQuery _queryBuilder) { _queryBuilder.onProduct(new Storefront.ProductQueryDefinition() { @Override public void define(Storefront.ProductQuery _queryBuilder) { _queryBuilder.title(); } }); } });}}); QueryGraphCall call = cl.queryGraph(query2); call.enqueue(new GraphCall.Callback<Storefront.QueryRoot>() { @Override public void onResponse(@NonNull GraphResponse<Storefront.QueryRoot> response) { ***//I could not cast this as shown in github*** // Log.v("shop","boby : " + Storefront.Product)response.data())); } @Override public void onFailure(@NonNull GraphError error) {}});我不确定如何获取价格并检查价格是否已购买,如果尚未购买,请继续购买。没有关于查询和检索方法的详细文档。 最佳答案 您可以使用此查询来获取产品详细信息和价格: String productId = "your-product-id" Storefront.ProductQueryDefinition query = q -> q .title() .descriptionHtml() .tags() .collections(quw -> quw.first(1), args -> args.edges(collectionEdge -> collectionEdge.node(collectionQuery -> collectionQuery.title() ) ) ) .images(args -> args.first(250), imageConnection -> imageConnection .edges(imageEdge -> imageEdge .node(Storefront.ImageQuery::src) ) ) .options(option -> option .name() .values() ) .variants(args -> args.first(250), variantConnection -> variantConnection .edges(variantEdge -> variantEdge .node(variant -> variant .title() .availableForSale() .image(Storefront.ImageQuery::src) .selectedOptions(selectedOption -> selectedOption .name() .value() ) .price() ) ) ); mGraphClient.queryGraph(Storefront.query( root -> root .node(new ID(productId), node -> node .onProduct(query) ) ) ).enqueue(new GraphCall.Callback<Storefront.QueryRoot>() { @Override public void onResponse(@NonNull GraphResponse<Storefront.QueryRoot> response) { final Storefront.Product product = (Storefront.Product) response.data().getNode(); } @Override public void onFailure(@NonNull GraphError error) { } });如果您想知道用户是否已经购买了产品,则需要将其保存在服务器上或为使用移动支付sdk(here)进行购买的用户创建客户帐户,然后您可以获取用户的订单() 10-05 22:48