2

嗨,我正在使用下面提到的代码来拉取订单构造。但我无法从此查询中获取订单 ID 和订单详细信息。即使订单已确认,也无法获取订单 ID 和订单详情。目前我正在使用 shopify mobilebuysdk:buy3:3.1.1

graphClient!!.queryGraph(query).enqueue(
    object : GraphCall.Callback<Storefront.QueryRoot> {
        override fun onResponse(@NonNull response: GraphResponse<Storefront.QueryRoot>) {

            if (response.data()!!.getNode() as Storefront.Checkout != null) {
                val checkout = response.data()!!.getNode() as Storefront.Checkout
                println("CheckOut : " + checkout)

                if (checkout != null) {

                    if (checkout.getOrder() != null) {
                        if (checkout.getOrder().getId().toString() != null) {
                            val orderId = checkout.getOrder().getId().toString()
                            println("Order ID : " + orderId)
                        }
                    }

                }


            }


        }

        override fun onFailure(@NonNull error: GraphError) {}
    }, null,
    RetryHandler.exponentialBackoff(1, TimeUnit.MILLISECONDS, 1.2f)
            .whenResponse<Storefront.QueryRoot> { response ->
                (response.data()?.getNode() as Storefront.Checkout).getOrder() == null
            }
            .maxCount(10)
            .build())
4

2 回答 2

0
val checkoutId = ID(tinyDB!!.getString("New_checkoutID"))
    val query = Storefront.query({ rootQuery ->
        rootQuery
                .node(checkoutId, { nodeQuery ->
                    nodeQuery
                            .onCheckout({ checkoutQuery ->
                                checkoutQuery
                                        .order({ orderQuery ->
                                            orderQuery
                                                    .orderNumber()
                                                    .totalPrice()
                                                    .processedAt()
                                        }

                                        )
                            }
                            )
                }
                )
    }
    )    

graphClient!!.queryGraph(query).enqueue(
            object : GraphCall.Callback<Storefront.QueryRoot> {
                override fun onResponse(@NonNull response: GraphResponse<Storefront.QueryRoot>) {
                    val checkout = response.data()!!.getNode() as Storefront.Checkout
                    val orderId = checkout.getOrder().getId().toString()
                }

                override fun onFailure(@NonNull error: GraphError) {}
            }, null,
            RetryHandler.exponentialBackoff(1, TimeUnit.MILLISECONDS, 1.2f)
                    .whenResponse<Storefront.QueryRoot>(
                            { response -> (response.data().getNode() as Storefront.Checkout).getOrder() == null }
                    )
                    .maxCount(10)
                    .build()
    )
于 2017-11-13T10:25:43.943 回答
0

看看这个答案, Shopify Web Checkout Issue

首先是从 QraphQL 设置中删除 HttpCachePolicy。在它尝试提供 Network_Only 来订购状态 api 之后。

你的问题就会消失。

于 2020-04-27T05:41:20.083 回答